3

I want to create a picture like the one attached below using tikzpicture. I could only draw two concentric circles. How do I colour them as in the picture?

Can anyone help me? I am pretty new to usage of TikZ.

wanted

  • 1
    Can you edit your post to include what you've gotten so far? – Arun Debray Apr 17 '16 at 19:53
  • \filldraw[blue] (0,0) circle (1cm); does not work? I assume, you mean fill, not shading – user31729 Apr 17 '16 at 19:56
  • Welcome! Please always include a minimal document we can compile to reproduce the situation. Very frustrating when somebody says 'I can only draw ... - I can't add the last arrow' and then fails to include any code, so that anybody who wants to help has to draw all of the ... before they can even see what the problem is with the last arrow, which they might not be able to help with anyway. ;) – cfr Apr 17 '16 at 20:23
  • @cfr: I'll keep this in mind. Yeah, I should have added a document showing what I've done so far. – pikachuchameleon Apr 17 '16 at 20:36
4

A PSTricks solution:

\documentclass{article}

\usepackage{pstricks}

\begin{document}

\begin{pspicture}(4,3)
 \psset{fillstyle = solid}
  \psframe[fillcolor = orange](0,0)(4,3)
  \pscircle(2,1.5){1}
  \pscircle[fillcolor = cyan](2,1.5){0.8}
\end{pspicture}

\end{document}

output1

In case you want the fill color of the ring to be the same as the background color, you can do the following:

\documentclass{article}

\usepackage{pstricks}
\usepackage{pagecolor}
\def\bgcolor{green!50} % background color
\pagecolor{\bgcolor}

\begin{document}

\begin{pspicture}(4,3)
 \psset{fillstyle = solid}
  \psframe[fillcolor = orange](0,0)(4,3)
  \pscircle[fillcolor = \bgcolor](2,1.5){1}
  \pscircle[fillcolor = cyan](2,1.5){0.8}
\end{pspicture}

\end{document}

output2

| improve this answer | |
  • 1
    Does this fill the outer ring with white or avoid filling it? I'm not sure which is wanted - just curious. – cfr Apr 17 '16 at 23:07
  • @cfr It fills with white. (See updated answer for a workaround.) – Svend Tveskæg Apr 17 '16 at 23:29
  • 1
    Thanks! I can't upvote again, though .... – cfr Apr 17 '16 at 23:31
7

Here is a suggestion using the even odd rule to fill the orange area, i.e. the rectangle without the outer circle.

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \path[fill=orange,even odd rule]
    (-4, -4) rectangle (4,4)
    (0,0)circle[radius=2]
  ;
  \path[fill=blue] 
    (0,0) circle [radius=1.5]
  ;
  \path[draw,very thick]
    (0,0) foreach \r in {1.5,2}{circle [radius=\r]}
  ;
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |
2

I think it's easiest to do this by shading the whole picture, and then drawing a white circle and a blue one.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    % fills entire rectangle
    \fill[orange] (-4, -4) rectangle (4,4);
    % removes filling inside circle
    \filldraw[fill=white, draw=black, very thick] (0,0) circle (2cm);
    % adds blue circle
    \filldraw[fill=blue, draw=black, very thick] (0,0) circle (1.5cm);
\end{tikzpicture}
\end{document}

enter image description here

| improve this answer | |
  • 3
    It doesn't really 'remove filling'. It just fills over it with white. If the page is coloured, you'll see the white and not the background colour. – cfr Apr 17 '16 at 20:25

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.