Graphics, Figures & TablesFill In Graph

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

Fill In Graph

Post by coachbennett1981 »

Hey Everyone,

I have tried FillBetween and am now trying to use intersecting segments from a post I had on a different site. I am trying to create this graph from AP Classroom. I can't get the fill correct. If anyone could help, that would be great. I have tried many different combinations of L1--R2, etc with 2-3 terms, but can't get it right. I have also read the literature, but I just don't understand it. I have included a picture of what I am trying to complete.

Code: Select all

Code, edit and compile here:
\documentclass[border=5mm]{article}
\usepackage{tikz,asymptote,ragged2e}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{backgrounds}
\pgfplotsset{compat=newest}
\usetikzlibrary{calc}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{
interpret as polar/.style={
x filter/.code=\pgfmathparse{cos(rawx)*rawy},
y filter/.code=\pgfmathparse{sin(rawx)*rawy}
}
}
\begin{document}
\begin{Center}
\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:180,
samples=360,
smooth,
interpret as polar
]
(x,{1-2*cos(x)});
\addplot[name path=B,
very thick,
domain=0:360,
samples=360,
smooth,
interpret as polar
] (x,{1});
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Attachments
Screenshot 2025-03-13 at 7.52.31 PM.png
Screenshot 2025-03-13 at 7.52.31 PM.png (44.39 KiB) Viewed 8514 times

Recommended reading 2024:

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

Re: Fill In Graph

Post by Stefan Kottwitz »

Hi Nick,

here's a quick idea - fill more with R*--L* and then fill the section with white as you did before:

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:180,
samples=100,
smooth,
interpret as polar
]
(x,{1-2*cos(x)});
\addplot[name path=B,
very thick,
domain=0:360,
samples=100,
smooth,
interpret as polar
] (x,{1});
\addplot[name path=B,
very thick,
domain=0:360,
samples=100,
smooth,
interpret as polar
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
filled-plot.png
filled-plot.png (22.62 KiB) Viewed 8442 times
Stefan
LaTeX.org admin
Post Reply