Wednesday, 21 August 2013

How do I shade an area in pgfplots?

How do I shade an area in pgfplots?

How do I create a shaded area in a polygon created by plot intersections?
In this case, up to the solid line without circle marks.
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}
\begin{axis}[
enlarge x limits=false,
axis on top,
enlarge y limits=true,
ymin=0,
symbolic x coords={Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec},
xtick=data,
]
\addplot[dashed] coordinates
{(Jan,5.5) (Feb,5.5) (Mar,5.5) (Apr,5.5) (May,5.5) (Jun,5.5) (Jul,5.5)
(Aug,5.5) (Sep,5.5) (Oct,5.5) (Nov,5.5) (Dec,5.5)};
\addplot [black,mark=circle] coordinates
{(Jan,3.2) (Feb,4) (Mar,4.5) (Apr,4.7) (May,5.5) (Jun,6.7) (Jul,6.5)
(Aug,5.5) (Sep,4.7) (Oct,4.5) (Nov,4) (Dec,3.2)};
\addplot [black,mark=*,mark options=solid] coordinates
{(Jan,3) (Feb,3.8) (Mar,4.3) (Apr,4.5) (May,5.3) (Jun,6.5) (Jul,6.3)
(Aug,5.3) (Sep,4.5) (Oct,4.3) (Nov,3.8) (Dec,3)};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

No comments:

Post a Comment