LATEX 删除极坐标图中阴影区域的部分

LATEX 删除极坐标图中阴影区域的部分

我一直在使用 TikZ 创建下面的图片。

在此处输入图片描述

以下是我所得到的代码。

\documentclass[width=5cm, height=5cm, border=2mm]{standalone}   
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[>=latex]

% cartesian coordinates
\draw[-] (-2cm,0cm) -- (2cm,0cm) node[right,fill=white] {$x$};
\draw[-] (0cm,-1cm) -- (0cm,3.1cm) node[above,fill=white] {$y$};

% sine graph with shading
\draw [thick, domain=0:2*pi, samples=200, smooth] plot (xy polar cs:angle=\x r,radius= 
{1+1*sin(\x r)});
\filldraw [thick, even odd rule, fill=gray!50, fill opacity=0.3, domain=pi/6:5*pi/6, 
samples=200, smooth] plot (xy polar cs:angle=\x r,radius= {1+1*sin(\x r)}) 
(0,1.5)circle(1.5cm);

\end{tikzpicture} 
\end{document}

我尝试使用此代码首先绘制正弦图(底部有一个小凹坑的图),然后绘制阴影圆图。正弦图只存在于 pi/6 和 5pi/6 之间,因此它将使用现有的阴影圆“偶数奇数规则”并删除该区域内的阴影,但如下所示,它并没有像我预期的那样发挥作用。请原谅我对奇偶规则,这对我来说很新,我仍在学习如何熟练地使用它。

上述代码生成以下极坐标图。

在此处输入图片描述

我怎样才能去除明显的灰色半圆,以便它看起来就像上面的草图一样?

提前欢呼!

答案1

此解决方案不使用该even odd rule选项,只是利用您知道交点的事实

\documentclass[width=5cm, height=5cm, border=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[>=latex]

% cartesian coordinates
\draw[-] (-2cm,0cm) -- (2cm,0cm) node[right,fill=white] {$x$};
\draw[-] (0cm,-1cm) -- (0cm,3.1cm) node[above,fill=white] {$y$};

% sine graph with shading
\fill [thick, fill=gray!50, fill opacity=0.3, domain=pi/6:5*pi/6,
samples=200, smooth] plot (xy polar cs:angle=\x r,radius= {1+1*sin(\x r)})
arc (210 : -30 : 1.5);
\draw [thick, domain=0:2*pi, samples=200, smooth] plot (xy polar cs:angle=\x r,radius=
{1+1*sin(\x r)}) (0, 1.5) circle (1.5cm);

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容