1

Having a bit of a tough time figuring out what tikz/pgf want from me here. I've tried a few solutions from previous askers, and still can't seem to get anywhere. When I use \addplot fill between [of=A and B];, my polar axis disappears completely and no shading occurs regardless of other settings like color and opacity. Here's an example:

\begin{tikzpicture}
    \begin{polaraxis}[axis on top,
        xticklabels={,0,$\frac\pi6$,$\frac\pi3$,$\frac\pi2$,$\frac{2\pi}3$,$\frac{5\pi}6$,$\pi$,$\frac{7\pi}6$,$\frac{4\pi}3$,$\frac{3\pi}2$,$\frac{5\pi}3$,$\frac{11\pi}6$}
        ]
    \addplot+[name path = A, mark=none,domain=0:720,samples=600, black] 
        {3*sin(3 * x)};
    \addplot+[name path = B, mark=none,domain=0:720,samples=600, black] 
        {3*cos(3 * x)};]
    % \tikzfillbetween[of=A and B]{gray, opacity=0.5}
    % equivalent to (x,{sin(..)cos(..)}), i.e.
    % the expression is the RADIUS
    \addplot fill between [of=A and B];
    \end{polaraxis}
\end{tikzpicture}

disappeared axis

Another asker found a solution with \tikzfillbetween[of=A and B]{gray, opacity=0.5}, but it doesn't seem to do the job of filling the intersection of the two paths, at least in the context of a polar axis (fill between works beautifully in a rectangular axis!). It does great at filling in the union, but I'm looking for the intersection.
enter image description here

For reference, here's a fill between example from elsewhere in the same paper.
enter image description here
I totally understand if it's just not possible given the current version of pgf, but it'd be neat to know for sure. Thanks so much!

1 Answer 1

2

Here is a more primitive, yet working way to fill the intersection of both curves.

\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
%\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.17}
\makeatletter
\tikzset{reuse path/.code={\pgfsyssoftpath@setcurrentpath{#1}}}
\makeatother
\begin{document}
\begin{tikzpicture}
  \begin{polaraxis}[axis on top,
        xticklabels={,0,$\frac\pi6$,$\frac\pi3$,$\frac\pi2$,$\frac{2\pi}3$,$\frac{5\pi}6$,$\pi$,$\frac{7\pi}6$,$\frac{4\pi}3$,$\frac{3\pi}2$,$\frac{5\pi}3$,$\frac{11\pi}6$}
        ]
    \addplot[save path=\pathA, mark=none,domain=0:720,samples=600, black] 
        {3*sin(3 * x)};
    \addplot[save path=\pathB,  mark=none,domain=0:720,samples=600, black] 
        {3*cos(3 * x)};
    \clip[reuse path=\pathA];
    \fill[gray,opacity=0.5,reuse path=\pathB];
  \end{polaraxis}
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.