8

How can we shade a partial annulus?

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\draw (-3.5,0)--(3.5,0) node[right]{$x$}; 
\draw (0,-3.5)--(0,3.5) node[above]{$y$};
\draw (1,0) arc (0:90:1);
\draw (3,0) arc (0:90:3);
\node at (1.3,1.3) {$R$};
\end{tikzpicture}

\end{document}
Qrrbrbirlbel
  • 119,821

3 Answers3

9

This is best done in one path.

\filldraw[fill=gray] (1,0) arc [radius=1, start angle=0, delta angle=90]
                  -- (0,3) arc [radius=3, start angle=90, delta angle=-90]
                  -- cycle;

Or, if you’re feeling funny, for a fake filling, you can use the double option which draws one bold black arc followed by a slightly smaller gray arc on top of it. I don’t recommend it (especially not for such big line widths) but it can be used.

\draw[double distance=2cm-\pgflinewidth, double=gray]
  (2cm,0cm) arc [radius=2cm, start angle=0, delta angle=90];

Output

enter image description here

Qrrbrbirlbel
  • 119,821
4

Just for fun with PSTricks.

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-.5,-.5)(3.5,3.5)
\psaxes[labels=none,ticks=none]{->}(0,0)(-.5,-.5)(3,3)[$x$,0][$y$,90]
\pscustom[fillstyle=solid,fillcolor=lightgray]
{
    \psarc(0,0){2.5}{0}{90}
    \psarcn(0,0){1.5}{90}{0}
    \closepath
}
\rput(2;45){\large$R$}
\end{pspicture}
\end{document}

enter image description here

3

Just to show another possibility with clip.

\documentclass{article}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\begin{scope}
\clip (0,0) rectangle (4,4);
\draw[fill=gray] (0,0) circle (3cm);
\draw[fill=white] (0,0) circle (1cm);
\end{scope}
\draw (-3.5,0)--(3.5,0) node[right]{$x$};
\draw (0,-3.5)--(0,3.5) node[above]{$y$};
\node at (1.3,1.3) {$R$};    
\end{tikzpicture}    
\end{document}

enter image description here