3

I am using PGFPlots version 1.14 and PGF version 3.0.1a and am having a weird effect with fill between. The coloring for fill between is appearing in the subsequent graph, not in the graph it was defined in.

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween, polar}
\begin{document}

\begin{center}
\begin{tikzpicture}
\begin{polaraxis}[
xtick=\empty,
ytick=\empty,
hide axis, 
]
\addplot[domain=0:360, smooth, blue, name path=rose]{cos(2*x)};
\addplot[domain=0:360, smooth, red, name path = circle]{.5};
\addplot[yellow] fill between[of=circle and rose];
\end{polaraxis}
\end{tikzpicture}
\end{center}


\begin{center} 
\begin{tikzpicture}
\begin{axis}
\addplot[green] fill between[of=NoPathA and NoPathB];
\end{axis}
\end{tikzpicture}
\end{center}

\end{document}

with result

enter image description here

Why isn't the fill happening in the original picture, and why is the fill showing up in the second picture, even when I put in dummy name paths?

  • Apparently the problem is caused by polaraxis. Although the plot would be different, in axis environment everything seems O.K. – Sina Ahmadi Sep 21 '17 at 19:14
  • BTW, you could stand to up the number of samples. – John Kormylo Sep 21 '17 at 20:24
4

Apparently the problem is caused by the polaraxis when filling between the two plots.

Here is my solution for your problem:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween, polar}
\begin{document}

\begin{center}
\begin{tikzpicture}
\begin{polaraxis}[hide axis]
\begin{scope}[]
\addplot[domain=0:360, smooth, blue, name path=rose]{cos(2*x)};
\addplot[domain=0:360, smooth, red, name path = circle]{.5};
\tikzfillbetween[of=rose and circle]{yellow}
  \end{scope}
  \end{polaraxis}
\end{tikzpicture}
\end{center}

\end{document}

which produces the following plot:

enter image description here

  • 1
    The scope doesn't appear to be needed. – John Kormylo Sep 21 '17 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.