I have been trying to figure out how to fill in this polar graph. I need to fill the intersection of the circle and function r=4+4cos x. I have been able to fill the whole circle in, but as you can see from my graph, I am missing the fill portion from the y-axis os the graph of r. I have tried to use Stefan's suggestion from this post I created viewtopic.php?t=36181, but I can't seem to figure out the intersections properly to "fill" what I don't want in blue.
Any help would be appreciated.
Code: Select all
Code, edit and compile here:
\documentclass[border=5mm]{standalone}\usepackage{pgfplots}\pgfplotsset{compat=1.18}\usepgfplotslibrary{fillbetween}\usetikzlibrary{backgrounds,arrows.meta}\pgfplotsset{interpret as polar/.style={x filter/.code=\pgfmathparse{cos(rawx)*rawy},y filter/.code=\pgfmathparse{sin(rawx)*rawy}}}\begin{document}\begin{tikzpicture}[>=Triangle]\begin{axis}[xtick distance=1,ytick distance=1,axis lines=center,axis equal image,enlargelimits=true,]\addplot[name path=A,very thick,domain=0:360,samples=100,smooth,interpret as polar](x,{4+4*cos(x)});\addplot[name path=B,very thick,domain=0:360,samples=100,smooth,interpret as polar] (x,{4});\path[name path=axis] (axis cs:0,0) -- (axis cs:1,0);\begin{scope}[on background layer]\clip (axis cs:0,0) circle (4);\fill[blue!30, opacity=0.5, intersection segments={of=A and B, sequence={R*--L*}}] -- cycle;