TeX - LaTeX Asked on January 24, 2021
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,$fracpi6$,$fracpi3$,$fracpi2$,$frac{2pi}3$,$frac{5pi}6$,$pi$,$frac{7pi}6$,$frac{4pi}3$,$frac{3pi}2$,$frac{5pi}3$,$frac{11pi}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}
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.
For reference, here’s a fill between
example from elsewhere in the same paper.
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!
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,$fracpi6$,$fracpi3$,$fracpi2$,$frac{2pi}3$,$frac{5pi}6$,$pi$,$frac{7pi}6$,$frac{4pi}3$,$frac{3pi}2$,$frac{5pi}3$,$frac{11pi}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}
Correct answer by user228539 on January 24, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP