2

I don't know how to fill an arc in the chart below

\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}

enter image description here

My attempt is in the end of the diagram

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

but it does not do anything. I would like to draw something like the image below enter image description here

  • What arc? I think there was a similar question though... – Alenanno Sep 7 '16 at 21:20
  • The command you use is a line, it won't fill because it's not an area. If you did a curve, it would fill that area. Can you draw the area you want to fill with some external program? Just to show what you want to achieve, because I'm not sure. – Alenanno Sep 7 '16 at 21:25
2

If you want the outer border to be an arc, then you can modify your filling command to something like

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

If you want a triangle, as in your image, you can do something like

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

In both cases, modify the angles and radius to suit your need.

enter image description here

Complete code:

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.