1

I want to fill region between two half circles using tikz. Here is what I tried and failed.

\documentclass[a4paper,12pt]{article}
\begin{tikzpicture}
\draw [-, ] (-3,0) --(-0.4,0);
\draw [-, ] (0.4,0) --(3,0);
\fill[gray!15]  ( -3,-3) |- (-0.4,0) arc (-180:0:4mm)-- (3,0) -| 
 (3,-3);
\draw [blue,thick,domain=180:360] plot ({.4*cos(\x)}, {.4*sin(\x)});
\draw [blue,thick,domain=180:360] plot ({3*cos(\x)}, {3*sin(\x)});
\end{tikzpicture}
\end{document}
2
  • Do post your \documentclass[]{} to \end{document}@Physics Moron
    – Biki Teron
    Jul 18, 2017 at 14:55
  • your MWE is still not complete :(
    – Zarko
    Jul 18, 2017 at 15:31

1 Answer 1

2

Like this?

enter image description here

\documentclass[tikz,margin=3mm]{standalone}

\begin{document}
\begin{tikzpicture}
\draw [-]  ( -3,0) -- (-0.4,0)
           (0.4,0) -- (3,0);
\fill[gray!15]  (-3,0)  -- (-0.4,0) arc (-180:0: 4mm) 
                        -- (3,0)    arc (0:-180:30mm); % <-- changed
\draw [blue,thick,domain=180:360] plot ({.4*cos(\x)}, {.4*sin(\x)});
\draw [blue,thick,domain=180:360] plot ({ 3*cos(\x)}, { 3*sin(\x)});
\end{tikzpicture}
\end{document}

Addendum: Considering Paul Gaborit comment below, your MWE can be simplified and improved with use arc instead to draw plot function:

\documentclass[tikz,margin=3mm]{standalone}

\begin{document}
\begin{tikzpicture}
\draw [-]   ( -3,0) -- (-0.4,0)
            (0.4,0) -- (3,0);
\fill[gray!15]      (-3,0) -- (-0.4,0) arc (-180:0: 4mm)
                           -- (3,0)    arc (0:-180:30mm); 
\draw[blue,thick]   (.4,0) arc (0:-180: 4mm); % <-- changed
\draw[blue,thick]   ( 3,0) arc (0:-180:30mm); % <-- changed
\end{tikzpicture}
\end{document}
2
  • You may replace the plot operations by arc operations... ;-) Jul 19, 2017 at 9:39
  • yes, as is done in drawing fill. added in answer (and also corrected some superfluous in the first code.
    – Zarko
    Jul 19, 2017 at 9:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .