16

I have very limited LaTeX knowledge. I am trying to plot the following figure using "tikz" and I appreciate if anyone can help me to finish plotting my figure. I did the following so far:

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

\begin{tikzpicture}

\draw (0,0) arc (0:180:6);
\draw   (-12,0)  - -(0,0);
\draw (-8,0) arc (0:180:2);
\draw (0,0) arc (0:180:4);
\draw (-6,-0.1) - - (-6,0.1);

\end{tikzpicture}

\end{document}

There is a BIG semi-circle and two inner SMALL semi-circles. I want to label the right endpoint of the BIG semi-circle by "A" and the left endpoint of the BIG semi-circle by "B". I want to label the center of the BIG semi-circle by "O", and I want to label the point where the two SMALL semicircles meet by "P". I also want to shade the area inside the BIG semi-circle and outside the two SMALL semi-circles. I also want to mention on the figure that the radius of the big circle is: 6. and the distance between the point "O" and the point "P" is "x"

Any help is much appreciated

6
  • @Pleasedonttouch that's a bit too much meaning change for the title. Can you narrow down its focus? They are just semicircles
    – percusse
    Commented Aug 2, 2014 at 10:31
  • @Pleasedon'ttouch Yes but it's not your question title. Better consult the OP
    – percusse
    Commented Aug 2, 2014 at 12:38
  • @Pleasedon'ttouch Or you are testing his/her patience.
    – percusse
    Commented Aug 2, 2014 at 12:41
  • @percusse: I am testing your patience. :-) Commented Aug 2, 2014 at 12:43
  • @Pleasedon'ttouch That would take a while then.
    – percusse
    Commented Aug 2, 2014 at 13:52

4 Answers 4

16

You can also draw that path at one go so you don't need to fill white to restrict the fill if you have something else underneath it. And while you are at it you can also place the labels and coordinates too.

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\filldraw[fill=blue] (0,0) 
               coordinate[label=-90:$B$] (B)
               arc (180:0:3cm) 
               coordinate[label=-90:$A$] (A)
               arc (0:180:2cm)
               coordinate[label=-90:$P$] (P)
               arc (0:180:1cm);
\draw (B)--(A) coordinate[midway,label=-90:$O$] (O);
\draw[decoration={brace,raise=5mm},decorate] (A) -- (O) 
                   node [midway,yshift=-6mm,below] (R) {$6$};
\draw[decoration={brace,raise=5mm},decorate] (O) -- (P)
                   node [midway,yshift=-6mm,below] (r) {$x$};
\end{tikzpicture}
\end{document}

enter image description here

6
  • Shouldn't it be pathreplacing instead of pathmorphing in line 2 of your code? Correct me if I'm wrong.
    – AboAmmar
    Commented Aug 2, 2014 at 8:49
  • @AboAmmar Actually, it shouldn't even be there because it loads brace by default but you are right. I forgot to remove it from another example code.
    – percusse
    Commented Aug 2, 2014 at 9:37
  • I think no, it should be still there to draw the braces. There must be decorations.pathreplacing.
    – AboAmmar
    Commented Aug 2, 2014 at 10:48
  • @AboAmmar Try removing it. snake, brace and one other thing I don't remember is loaded by default.
    – percusse
    Commented Aug 2, 2014 at 10:51
  • @percusse- It doesn't work if I remove it. Does it work with you?
    – AboAmmar
    Commented Aug 2, 2014 at 11:06
8

Here is a quick attempt:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \draw[fill=blue] (0,0)node[below]{$A$} arc (0:180:6) node[below]{$B$};
  \draw (-12,0) - -(0,0);
  \draw[fill=white] (-8,0) arc (0:180:2);
  \draw[fill=white] (0,0) arc (0:180:4)node[below]{$P$};
  \draw (-6,-0.1) -- node[below]{$O$} (-6,0.1);
  \draw[<->](-8,-0.6)--node[below]{$x$}(-6,-0.6);
  \draw[<->](-6,-0.6)--node[below]{$6$}(0,-0.6);
\end{tikzpicture}

\end{document}

This produces:

enter image description here

Note that colouring/filling is cumulative: you can fill one region with a colour and then fill another overlapping region with a different colour, or white to remove the colour. The last colour in any given region wins.

0
5

No arcs but with circles and clip.

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[font=\footnotesize]
\begin{scope}
\clip (-3.1,-0.5\pgflinewidth) rectangle (3,3.1);
\filldraw[fill=blue] (0,0)  circle (3cm);
\filldraw[fill=white] (1,0) circle (2cm);
\filldraw[fill=white] (-2,0) circle (1cm);
\end{scope}
\draw (-3,-0.5\pgflinewidth)
        coordinate[label=-90:$B$] (B)
        -- (-1,-0.5\pgflinewidth) coordinate[label=-90:$P$] (P)
        --coordinate[pos=0.25,label=-90:$O$] (O)
        (3,-0.5\pgflinewidth)coordinate[label=-90:$A$] (A) ;
\draw[|<->|,yshift=-5mm] ([yshift=-5mm]A) -- ([yshift=-5mm]O)
                   node [midway,below] (R) {$6$};
\draw[|<->|] ([yshift=-5mm]O) -- ([yshift=-5mm]P)
                   node [midway,below] (r) {$x$};
\end{tikzpicture}
\end{document}

enter image description here

4

A recommended solution (by me) with PSTricks.

\documentclass[pstricks,border=12pt,dvipsnames]{standalone}
\usepackage{pst-eucl}

\begin{document}
\begin{pspicture}[showgrid=false](-5,-2)(5,5)
    \pstGeonode[PosAngle=-90]
        (0,0){O}
        (5,0){A}
        (-5,0){B}
        (-2,0){P}
    \begingroup
        \psset{PointName=none,PointSymbol=none}
        \pstMiddleAB{B}{P}{O'}
        \pstMiddleAB{P}{A}{O''}
    \endgroup
    \pscustom[fillstyle=solid,fillcolor=NavyBlue]
    {
        \pstArcOAB{O}{A}{B}
        \pstArcnOAB{O'}{B}{P}
        \pstArcnOAB{O''}{P}{A}
        \closepath
    }
    \pcline(B)(A)
    \psset{arrows=|*-|*,shortput=nab}
    \pcline[offset=-1](P)(O)_{$x$}
    \pcline[offset=-1.5](O)(A)_{$r$}
\end{pspicture}
\end{document}

enter image description here

1
  • 1
    The additional dots (to make the points clearer) are given free of charge. Commented Aug 2, 2014 at 12:28

You must log in to answer this question.

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