Ombrage entre les courbes à l'aide de l'axe polaire
J'utilise pgfplots
et trace les équations r=1
et r=1-sin(\x/2)
, mais je voudrais ombrer les 3 régions différentes formées par les courbes. J'ai trouvé un lien vers ce rapport de bogue demandant l'utilisation fill between
dans l' polaraxis
environnement qui renvoie à 2 autres articles TeX.SX:https://github.com/pgf-tikz/pgfplots/issues/124
Cet article nuance la zone contenant l'origine: Ombrage entre les graphiques de deux équations polaires dans pgfplots
Cet article utilise l' axis
environnement au lieu de l' polaraxis
environnement: ombrage d'une région entre deux courbes polaires
Voici le code avec lequel je travaille:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{polar, fillbetween}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}[scale=1]
\begin{polaraxis}
[
domain=0:360,
samples=180,
grid=both,
grid style={line width=0.1pt, draw=gray!75},
major grid style={black},
minor x tick num=3,
minor y tick num=3,
xmin=0, xmax=360,
ymin=0, ymax=2.25,
xtick={0,45,...,360},
xticklabels={},
ytick={3},
yticklabel style={anchor=north},
]
\addplot[draw=red, domain=0:720] {1-sin(\x/2)};
\addplot[draw=blue, domain=0:360] {1};
\end{polaraxis}
\end{tikzpicture}
\end{document}

Réponses
Voici une méthode qui n'est pas très sophistiquée mais qui fonctionne.
\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar, fillbetween}
\pgfplotsset{compat=newest}
\makeatletter
\tikzset{reuse path/.code={\pgfsyssoftpath@setcurrentpath{#1}}}
\makeatother
\begin{document}
\begin{tikzpicture}[scale=1]
\pgfplotsset{set layers}
\begin{polaraxis}
[axis on top,
domain=0:360,
samples=180,
grid=both,
grid style={line width=0.1pt, draw=gray!75},
major grid style={black},
minor x tick num=3,
minor y tick num=3,
xmin=0, xmax=360,
ymin=0, ymax=2.25,
xtick={0,45,...,360},
xticklabels={},
ytick={3},
yticklabel style={anchor=north},
]
\addplot[draw=red, domain=0:720,save path=\RedPath] {1-sin(\x/2)};
\addplot[draw=blue, domain=0:360,save path=\BluePath] {1};
\pgfonlayer{axis background}
\fill[blue!20,reuse path=\BluePath];
\fill[red!20,even odd rule,reuse path=\RedPath];
\clip[reuse path=\BluePath];
\fill[cyan!20,even odd rule,reuse path=\RedPath];
\endpgfonlayer
\end{polaraxis}
\end{tikzpicture}
\end{document}
