極軸を使用した曲線間のシェーディング
Nov 29 2020
pgfplots
方程式r=1
とを使用してプロットしていますr=1-sin(\x/2)
が、曲線によって形成される3つの異なる領域に陰影を付けたいと思います。私はこのバグレポートへのリンクを使用してについて尋ねたfill between
中polaraxis
2件の他のTeX.SXの記事にリンク環境:https://github.com/pgf-tikz/pgfplots/issues/124
この投稿は、原点を含む領域に陰影を付けます。pgfplotsの2つの極方程式のグラフ間の陰影付け
この投稿では、axis
環境の代わりに環境を使用しています。2つの極線の間の領域をシェーディングしpolaraxis
ます。
これが私が扱っているコードです:
\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}

回答
5 Noname Nov 29 2020 at 07:10
これはあまり洗練されていないが機能する方法です。
\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}
