Graphics, Figures & TablesMore Fill Between Questions

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

More Fill Between Questions

Post by coachbennett1981 »

Hey Everyone,

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;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Stefan Kottwitz
Site Admin
Posts: 10308
Joined: Mon Mar 10, 2008 9:44 pm

Re: More Fill Between Questions

Post by Stefan Kottwitz »

Hi Nick,

you can fill the path between A and the axis, and clip with the circle:

Code: Select all

Code, edit and compile here:
\begin{scope}[on background layer]
\clip (axis cs:0,0) circle (4);
\fill[blue!30, opacity=0.5, intersection segments={
of= A and axis, sequence = {R*--L*}
}] -- cycle;
\end{scope}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
fill-intersection.png
fill-intersection.png (31.93 KiB) Viewed 548 times
Stefan
LaTeX.org admin
coachbennett1981
Posts: 274
Joined: Fri Feb 05, 2010 10:15 pm

Re: More Fill Between Questions

Post by coachbennett1981 »

Thank you! I appreciate it! For some reason ( I believe the fill is the issue) but the colors are off. (See image)
filling.png
filling.png (63.5 KiB) Viewed 525 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10308
Joined: Mon Mar 10, 2008 9:44 pm

Re: More Fill Between Questions

Post by Stefan Kottwitz »

I think that's because you still have a second \fill command; as you had two \fill before, I do only one \fill. It adds with opacity/transparency.

Stefan
LaTeX.org admin
Post Reply