mkrphys / ipython-tikzmagic

IPython magics for generating figures with TikZ
BSD 3-Clause "New" or "Revised" License
160 stars 44 forks source link

add `--pgfplotslibrary` option #28

Closed joelkim closed 4 years ago

joelkim commented 5 years ago

Hi, I added a --pgfplotslibrary option to use fillbetween pgfplotslibrary.

The code:

%%tikz -p pgfplots -g fillbetween

\pgfmathdeclarefunction{gauss}{2}{%
  \pgfmathparse{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}%
}
\pgfplotsset{compat=1.10}

\begin{axis}[
domain=0:10,
samples=100,
enlargelimits=false,
]
\addplot [very thick, red!50!black, name path=f] {gauss(5,1)};
\addplot [name path=axis] coordinates {(0,0)(10,0)};
\addplot [thick,fill=green,fill opacity=0.4]
   fill between[of=f and axis,soft clip={domain=0:3.5}];
\addplot [thick,fill=red,fill opacity=0.4]
   fill between[of=f and axis,soft clip={domain=3.5:6.5}];
\addplot [thick,fill=green,fill opacity=0.4]
   fill between[of=f and axis,soft clip={domain=6.5:10}];
\end{axis}

generates the following figure.

image