绘制“极坐标矩形”(环形区域的一部分)

绘制“极坐标矩形”(环形区域的一部分)

我画了以下区域

在此处输入图片描述

使用代码

\documentclass[12pt]{article}
%tikzpicture
\usepackage{tikz}
%pgfplots
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepgfplotslibrary{statistics}
\usepgfplotslibrary{fillbetween}

\begin{document}
\pgfplotsset{
    unit vector ratio*=1 1 1,
    standard/.style={
    axis line style = thick,
    trig format=rad,
    enlargelimits,
    axis x line=middle,
    axis y line=middle,
    enlarge x limits=0.15,
    enlarge y limits=0.15,
    every axis x label/.style={at={(current axis.right of origin)},anchor=north west},
    every axis y label/.style={at={(current axis.above origin)},anchor=south east}
    }
}

\begin{tikzpicture}
\begin{axis}[standard,
            xtick={1,2},
            ytick={2},
            samples=1000,
            xlabel={$x$},
            ylabel={$y$},
            xmin=-2.25,xmax=2.25,
            ymin=-0.02,ymax=2.5]


\addplot[name path=F,domain={-2:2}]{sqrt(4-x*x)};
\addplot[name path=G, domain={-2:2}]{sqrt(1-x*x)};

\addplot[fill=black, fill opacity=0.2] fill between [of=F and G, soft clip={domain=-2:2}];

\end{axis}
\end{tikzpicture}

\end{document}

但是阴影区域效果不太好,特别是边界附近。有人有改进的想法吗?

一般来说,有没有一种方便的方法来绘制a≤r≤b且α≤θ≤β的极坐标矩形?

答案1

按照 Sigur 的建议,以下是完整的代码:

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}[scale=2]
        \draw[-latex] (-2.5,0)--(2.5,0) node[right] () {$x$};
        \foreach \i in {-2,-1,0,1,2}
        \draw[red] (\i,.2)--(\i,-.2) node[red,below] () {\small $\i$};
        \draw[-latex] (0,-.2)--(0,2.5) node[above] () {$y$};
        \foreach \j in {1,2}
        \draw[red] (.2,\j)--(-.2,\j) node[red,left,above] () {\small $\j$};
        \draw[fill=gray!10,opacity=.8] (1,0) -- (2,0) arc (0:180:2cm) -- (-1,0) arc (180:0:1cm) -- cycle;
    \end{tikzpicture}
\end{document}

此代码的输出:

在此处输入图片描述

编辑一些变化:

在此处输入图片描述

使用以下代码:

\documentclass[10pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}[scale=2]
        \draw[-latex] (-2.5,0)--(2.5,0) node[right] () {$x$};
        \draw[fill=gray!10,opacity=.8] (1,0) -- (2,0) arc (0:180:2cm) -- (-1,0) arc (180:0:1cm) -- cycle;
        \foreach \i in {-2,-1,0,1,2}
        \draw (\i,0)--(\i,-.1) node[below] () {\small $\i$};
        \draw[-latex] (0,-.1)--(0,2.5) node[above] () {$y$};
        \foreach \j in {1,2}
        \draw (0,\j)--(-.1,\j) node[left,above] () {\small $\j$};
    \end{tikzpicture}
\end{document}

相关内容