# How can I color fill the annulus with tikz?

I want to color the annulus between the circles with radius r_1 and r_3, but keep the lines of the circles and the lines r_1, r_2, r_3. I tried color fill, but the lines disappear.

Here is my tikz code:

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\draw[->,color=black, thick] (-3.66,0) -- (3.66,0);
\draw[shift={(\x,0)},color=black] (0pt,-2pt);
\draw[->,color=black, thick] (0,-3.66) -- (0,3.66);
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt);
\clip(-3.66,-4.4) rectangle (4.65,4.65);

\draw [name path=A, thick, draw=black](0,0) circle (1cm);
\draw [name path=B, thick, draw=black](0,0) circle (2cm);
\draw [name path=C, thick, draw=black](0,0) circle (1.5cm);
\draw [thick, draw=black](0,0)-- (0.76,0.64);
\draw [thick, draw=black](0,0)-- (1.13,1.65);
\draw [thick, draw=black](0,0)-- (0.37,1.45);

\begin{scriptsize}
\draw[color=black] (-1.54,1.94) node {$R$};
\draw[color=black] (1.11,0.73) node {$r_1$};
\draw[color=black] (1.48,1.81) node {$r_3$};
\draw[color=black] (0.55,1.69) node {$r_2$};
\end{scriptsize}

\end{tikzpicture}

• Welcome by the way. One thing to note when posting code for questions: It is always appreciated if make a complete document from \documentclass to \end{document}, containing the necessary packages, libraries and definitions (like in my answer). In this case for example, the arrows and intersections TikZ libraries are required to run the code, and the \x and \y macros are not defined in your code. (I didn't use them in my answer.) – Torbjørn T. Apr 26 '18 at 11:28

Things are drawn in the order in which they're defined, so if you draw lines first and fill afterwards, the filling will cover the lines. To fill only the region between the inner and outer circle, you can add the following at the very start of your diagram (right after \begin{tikzpicture}[...])

\fill [red,even odd rule] (0,0) circle[radius=2cm] circle[radius=1cm];


In the code below I introduce some other techniques to draw your diagram. The circles are drawn using a loop, the r_N labels are appended at the end of the radial lines, which themselves are drawn using polar coordinates (<angle>:<radius>)

I didn't include the name path stuff, as you didn't seem to be using it for anything, and I removed x=1cm,y=1cm and color=black, because those are the default anyway. I also replaced the triangle 45 arrow tip from the arrows library with Triangle from arrows.meta, as pgf considers the former library to be deprecated in favor of the latter.

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}[
line cap=round,
line join=round,
>=Triangle,
myaxis/.style={->,thick}
]

\begin{scope}[
every node/.append style={
circle,
font=\scriptsize,
inner sep=1pt
}]
\node at (135:2.5cm) {$R$};

% The following \foreach does the same as the three \draws immediately below
%   \draw [thick] (0,0) -- (\Ang:\Rad cm) node[anchor=180+\Ang] {$r_{\i}$};

\draw [thick] (0,0) -- (40:1cm) node[anchor=220] {$r_1$};
\draw [thick] (0,0) -- (55:2cm) node[anchor=235] {$r_3$};
\draw [thick] (0,0) -- (75:1.5cm) node[anchor=255] {$r_2$};
\end{scope}

\draw[myaxis] (-3.66,0) -- (3.66,0);
\draw[myaxis] (0,-3.66) -- (0,3.66);

\end{tikzpicture}
\end{document}


Like this? The order of drawing circles and lines matters. Also, you needn't say draw=black, it's the default.

\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]

\draw [name path=B, thick, draw,fill=blue!20](0,0) circle (2cm);
\draw [name path=C, thick, draw](0,0) circle (1.5cm);
\draw [name path=A, thick, draw,fill=white](0,0) circle (1cm);
\draw [thick](0,0)-- (0.76,0.64);
\draw [thick](0,0)-- (1.13,1.65);
\draw [thick](0,0)-- (0.37,1.45);

\draw[->, thick] (-3.66,0) -- (3.66,0);
\draw[->, thick] (0,-3.66) -- (0,3.66);

\begin{scriptsize}
\draw (-1.54,1.94) node {$R$};
\draw (1.11,0.73) node {$r_1$};
\draw (1.48,1.81) node {$r_3$};
\draw (0.55,1.69) node {$r_2$};
\end{scriptsize}

\end{tikzpicture}


• Yes, exactly like this! Thank you very much! – em11 Apr 26 '18 at 11:31