填充圆弧

填充圆弧

我不知道如何填充下面图表中的圆弧

\documentclass{standalone}
\usepackage[x11names]{xcolor}                     %Additional colors
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[>=latex]

% Draw the lines at multiples of pi/12
\foreach \ang in {0,...,31} {
  \draw [lightgray] (0,0) -- (\ang * 180 / 16:3);
}


% Add the labels at multiples of pi/4
\foreach \ang/\lab/\dir in {
  0/0/right,
  1/{\pi/4}/{above right},
  2/{\pi/2}/above,
  3/{3\pi/4}/{above left},
  4/{\pi}/left,
  5/{5\pi/4}/{below left},
  7/{7\pi/4}/{below right},
  6/{3\pi/2}/below} {
  \draw (0,0) -- (\ang * 180 / 4:3.1);
  \node [fill=white] at (\ang * 180 / 4:3.2) [\dir] {\scriptsize $\lab$};
}

% The double-lined circle around the whole diagram
\draw [style=thick] (0,0) circle (3);

% Concentric circles and radius labels
\foreach \s in {0, 1, 2} {
    \draw [SteelBlue3, thick] (0,0) circle (\s + 0.5);
    \draw (0,0) circle (\s);
    \node [fill=white] at (\s, 0) [below] {\scriptsize $\s$};
}

\draw[fill=red!50 ] (0,0) -- (0.5 * 180 :1);
\end{tikzpicture} 
\end{document}

在此处输入图片描述

我的尝试是在图表的末尾

\draw[fill=red!50 ] (0,0) -- (0.5 * 180 :1);

但它什么也没做。我想画一些类似下面的图片 在此处输入图片描述

答案1

如果您希望外边框为弧形,那么您可以将填充命令修改为类似

\draw[fill=red!50 ] (0,0) -- (0.5 * 180 : 2cm) arc[start angle=90,delta angle=-30,radius=2cm] -- cycle;

如果你想要一个三角形,就像你的图片中那样,你可以这样做

\draw[fill=red!50 ] (0,0) -- (180 : 2cm) -- (150:2cm)  -- cycle;

在两种情况下,修改角度和半径以满足您的需要。

在此处输入图片描述

完整代码:

\documentclass{standalone}
\usepackage[x11names]{xcolor}                     %Additional colors
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[>=latex]

% Draw the lines at multiples of pi/12
\foreach \ang in {0,...,31} {
  \draw [lightgray] (0,0) -- (\ang * 180 / 16:3);
}


% Add the labels at multiples of pi/4
\foreach \ang/\lab/\dir in {
  0/0/right,
  1/{\pi/4}/{above right},
  2/{\pi/2}/above,
  3/{3\pi/4}/{above left},
  4/{\pi}/left,
  5/{5\pi/4}/{below left},
  7/{7\pi/4}/{below right},
  6/{3\pi/2}/below} {
  \draw (0,0) -- (\ang * 180 / 4:3.1);
  \node [fill=white] at (\ang * 180 / 4:3.2) [\dir] {\scriptsize $\lab$};
}

% The double-lined circle around the whole diagram
\draw [style=thick] (0,0) circle (3);

% Concentric circles and radius labels
\foreach \s in {0, 1, 2} {
    \draw [SteelBlue3, thick] (0,0) circle (\s + 0.5);
    \draw (0,0) circle (\s);
    \node [fill=white] at (\s, 0) [below] {\scriptsize $\s$};
}

\draw[fill=red!50 ] (0,0) -- (0.5 * 180 : 2cm) arc[start angle=90,delta angle=-30,radius=2cm] -- cycle;

\draw[fill=blue!50 ] (0,0) -- (180 : 2cm) -- (150:2cm)  -- cycle;
\end{tikzpicture} 
\end{document}

相关内容