7

I am trying to draw the below given figure. Please help me to plot it in Tikz. I am only able to plot concentric circles. Concentric Cirlces. I would like to have different colors in between different circles. Also, the text should be along the curve. The arrow in between the two concentric circles does not have to overlap with the circle on the right hand side.

I would be grateful if you could help me in plotting this in Tikz. Please let me know if you need more information. Thanks!

\documentclass[conference]{IEEEtran}

\ifCLASSINFOpdf

\else

\fi

\usepackage[usenames,dvipsnames]{color}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes.multipart}
\usepackage[caption=false]{subfig}
\usepackage{tabularx,tikz}
\usepackage{graphicx}
\usepackage{color}
\usepackage{pdfpages}
\begin{document}

\title{Practice Tex}


\maketitle

\section{Introduction}

\begin{figure}
\begin{center}
\begin{tikzpicture} 

  \draw(0,0) circle (0.4cm)
  node[draw=none,sloped,above]{cxvzxcv};    


  \draw(0,0) circle (0.75cm) node[draw=none,sloped,above]{ratio};

  \draw(0,0) circle (1.25cm);
  \node[draw=none,align=center, font=\scriptsize,text width = 1.25cm] at (0,2.2) {22};

  \draw(0,0) circle (2cm);
  \node[draw=none,align=center, font=\scriptsize,text width = 1.25cm] at (0,3.8) {33333};

  \draw(0,-9) circle (0.4cm);
  \node[draw=none,align=center, font=\scriptsize,text width = 1.25cm] at (0,-9) {fsgsdgf};  

  \draw(0,-9) circle (0.75cm);
  \node[draw=none,align=center, font=\scriptsize,text width = 1.25cm] at (0,-7.8) {fgdsfg};

  \draw(0,-9) circle (1.25cm) node[midway,sloped] at (0,-9) {dfsdfad};

  \draw(0,-9) circle (2.8cm);
  \node[draw=none,align=center, font=\scriptsize,text width = 1.25cm] at (0,-6.4) {dfsdfsd};

  \draw(0,-9) circle (3.2cm);
  \node[draw=none,align=center, font=\scriptsize,text width = 1.25cm] at (0,-6) {dfsdfsd};

  \draw(0,-9) circle (3.6cm);
  \node[draw=none,align=center, font=\scriptsize,text width = 1.25cm] at (0,-5.6) {sfdsfd};

  \draw(0,-9) circle (4.4cm);
  \node[draw=none,align=center, font=\scriptsize,text width = 1.25cm] at (0,-4.8) {sdfsf}; 

  \pgfsetlinewidth{3pt} 
  \draw [-implies][->] (0,-4) -- (0,-4.6);


\end{tikzpicture} 
\end{center}
\end{figure}
\end{document}
9
  • 4
    As always, some compilable code to see how far have you gone or anything that shows a minimal effort on your side, is welcome. Right now this looks like a “do it for me” question. What is that you don't know? Drawing arrows? Drawing (curved) labels? Coloring the inside of a circle? All of these are already answered here.
    – Manuel
    Aug 15, 2014 at 21:23
  • 1
    Please remove everything from your code that is not relevant with your problem. That's what "minimal" in minimal working example (MWE) means.
    – jub0bs
    Aug 15, 2014 at 21:51
  • Here is my attempt. I did try to plot and have text along the curve but I could not get the text along the curve of a circle. Coloring inside the circle is fine for me but how will I have different colors in between different circles? I am very new to Tikz so I am unable to be innovative here. I would be thankful if you could help me with the plot. Thanks!
    – New User
    Aug 15, 2014 at 21:51
  • I did remove everything that is not needed but have kept the packages and few commented out code which might be required by the person who helps me. Kindly, let me know and I would be happy to trim it down even further. Thanks again !
    – New User
    Aug 15, 2014 at 21:53
  • A lot of packages loaded here are irrelevant to your problem: amsmath, algpseudocode, gnuplottex url, etc.
    – jub0bs
    Aug 15, 2014 at 21:55

3 Answers 3

13

Something like this is made with the libraries decorations.text and arrows.meta together with the correspondent options

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text,calc,arrows.meta}
\begin{document}
\begin{tikzpicture}
\coordinate (O) at (0,0);

\draw (O) circle (2.5);
\draw (O) circle (1.5);
\draw (O) circle (0.5);

\draw[decoration={text along path,reverse path,text align={align=center},text={Wee}},decorate] (0.6,0) arc (0:180:0.6);
\draw[decoration={text along path,reverse path,text align={align=center},text={There is a way?}},decorate] (1.6,0) arc (0:180:1.6);
\draw[decoration={text along path,reverse path,text align={align=center},text={Should be here any!}},decorate] (2.6,0) arc (0:180:2.6);

\begin{scope}[xshift=6cm]
\coordinate (O) at (0,0);
\draw[fill=red!30] (O) circle (2.8);
\draw[fill=green!40] (O) circle (2);
\draw[fill=yellow!70] (O) circle (1.2);
\draw[fill=blue!45] (O) circle (0.4);

\draw[decoration={text along path,reverse path,text align={align=center},text={xxx}},decorate] (0.5,0) arc (0:180:0.5);
\draw[decoration={text along path,reverse path,text align={align=center},text={yyy}},decorate] (1.3,0) arc (0:180:1.3);
%\draw[decoration={text along path,reverse path,text align={align=center},text={Should be here any!}},decorate] (2.1,0) arc (0:180:2.1);
\draw[decoration={text along path,reverse path,text align={align=center},text={Hello, how are you?}},decorate] (2.9,0) arc (0:180:2.9);
\end{scope}
\draw[line width=2mm,>={Triangle[length=3mm,width=5mm]},->] (2.6,0) -- (3.8,0);
\end{tikzpicture}
\end{document}

Result

enter image description here

EDIT

Or you can simplify the code a bit by using loops (\foreach)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text,calc,arrows.meta}
\begin{document}
\begin{tikzpicture}
\coordinate (O) at (0,0);
\foreach \j in {1,...,3} \draw (O) circle (3.5-\j);
\foreach \k/\text in {0/Should be here any!,1/There is a way?,2/Wee} \draw[decoration={text along path,reverse path,text align={align=center},text={\text}},decorate] (2.6-\k,0) arc (0:180:2.6-\k);
\begin{scope}[xshift=6cm]
\coordinate (O) at (0,0);
\foreach \k in {1,...,4}\pgfmathparse{12*\k} \draw[fill=red!\pgfmathresult] (O) circle (3.6-0.8*\k);
\foreach \k/\text in {0/{Hello, how are you?},1/,2/yyy,3/xxx} \draw[decoration={text along path,reverse path,text align={align=center},text={\text}},decorate] (2.9-0.8*\k,0) arc (0:180:2.9-0.8*\k);
\end{scope}
\draw[line width=2mm,>={Triangle[length=3mm,width=5mm]},->] (2.6,0) -- (3.8,0);
\end{tikzpicture}
\end{document}
0
9

Here is a beginning which demonstrates 2 ways to fill the spaces between the circles and one way to curve text around the circles. One basically fills the circles in reverse order of size so that the fill for smaller circles overrides the fill from earlier circles. The other uses the 'even odd rule' for a single fill between two circles.

The decorations.text library is key for fitting the text to the path. There are two main options: text along path and text effects along path. The first, which I think is simpler to use, is shown in this example.

I've done a couple of other things, here. The first is that I've defined a style to avoid repetition, ensure consistency and make it easier to make changes should you need to. The second is that I've specified a couple of coordinates so that it is easier to move the nests of circles around if you need to. (Just change the specification of c1 and/or c2 in one place and all should follow.) I've also updated the arrow to use the newer arrows.meta library.

EDIT: The code now demonstrates the use of a loop to colour and label the circles for the second set.

\documentclass[tikz]{standalone}

\usetikzlibrary{positioning,arrows.meta,decorations.text}
\usetikzlibrary{shapes.multipart}
\begin{document}

\begin{tikzpicture}
  [
    circle type 1/.style={draw=none,align=center, font=\scriptsize,text width = 1.25cm},
  ]

  \coordinate (c1) at (0,0);
  \coordinate (c2) at (0,-9);

  \path (c1) [draw, fill=red, decoration={text along path, text={Some text along the path}, reverse path}, postaction=decorate] circle (2cm);
  \path (c1) [draw, fill=orange] circle (0.4cm) node [draw=none,sloped,above] {cxvzxcv};
  \path [fill=blue, even odd rule, draw] (c1) circle (0.75cm) node[draw=none,sloped,above]{ratio} (c1) circle (1.25cm);

  \node[circle type 1] at (0,2.2) {22};

  \node[circle type 1] at (0,3.8) {33333};

  \foreach \i / \j [count=\ino] in {4.4cm/sdfsf, 3.6cm/sfdsfd, 3.2cm/dfsdfsd, 2.8cm/dfsdfsd, 1.25cm/dfsdfad, 0.75cm/fgdsfg, 0.4cm/fsgsdgf}
    {
      \pgfmathsetmacro{\colmixer}{mod(10*\ino,100)}%
      \path [draw, fill=blue!\colmixer, decoration={text along path, text={\j}, reverse path}, postaction=decorate] (c2) circle (\i);
    }

  \draw [-Implies, line width=3pt] (0,-4) -- (0,-4.6);

\end{tikzpicture}
\end{document}

Here is the first set of concentric circles:

Nested circles

Here is the second nest of circles coloured using the loop:

Circles coloured by loop

Update

In response to the question in comments, if you want the text at the top of the circle, rather than at the right, it is easiest to switch to arc construction so that you do not need to guess how far along the path the text should be. (The answer from skpblack uses this approach already.)

This version colours both sets of circles using loops and calculates the position for the arrows using the calc library so that the arrow goes into the second set of circles. I've also put that set on the right by adjusting the definition of c2.

\documentclass[tikz]{standalone}

\usetikzlibrary{positioning,arrows.meta,decorations.text,calc}
\usetikzlibrary{shapes.multipart}
\begin{document}

\begin{tikzpicture}
  [
    circle type 1/.style={draw=none,align=center, font=\scriptsize,text width = 1.25cm},
  ]

  \coordinate (c1) at (0,0);
  \coordinate (c2) at (9,0);

  \foreach \i / \j [count=\ino] in {2cm/Some text along the path, 1.25cm/Some more text along another path, 0.75cm/ratio, 0.4cm/cxvzxcv}
    {
      \pgfmathsetmacro{\colmixer}{mod(10*\ino,100)}%
      \path [draw, fill=red!\colmixer, decoration={text along path, text={\j}, text align=center, reverse path}, postaction=decorate] (c1) ++(0,-\i) arc (-90:270:\i);
    }

  \foreach \i / \j [count=\ino] in {4.4cm/sdfsf, 3.6cm/sfdsfd, 3.2cm/dfsdfsd, 2.8cm/dfsdfsd, 1.25cm/dfsdfad, 0.75cm/fgdsfg, 0.4cm/fsgsdgf}
    {
      \pgfmathsetmacro{\colmixer}{mod(10*\ino,100)}%
      \path [draw, fill=blue!\colmixer, decoration={text along path, text={\j}, text align=center, reverse path}, postaction=decorate] (c2) ++(0,-\i) arc (-90:270:\i);
    }

  \draw [-Implies, line width=3pt] ($(c1)!1/3!(c2)$) -- ($(c1)!2/3!(c2)$);

\end{tikzpicture}
\end{document}

two nests coloured using loops

Update II

The question was asked how to move the text inside the relevant circle. Here is one way to do that which involves using a second path with a slightly smaller circle to set the text after the main path has been drawn and filled. Because TeX cannot cope with doing this for the 0.4cm circles, these are excluded using a conditional based on the number of iterations of the loop. This test therefore depends on the number of circles in the nest. For the second set, it is the 7th circle which must be excluded; for the first set, it is the 4th.

\documentclass[tikz]{standalone}

\usetikzlibrary{positioning,arrows.meta,decorations.text,calc}
\usetikzlibrary{shapes.multipart}
\begin{document}

\begin{tikzpicture}
  [
    circle type 1/.style={draw=none,align=center, font=\scriptsize,text width = 1.25cm},
  ]

  \coordinate (c1) at (0,0);
  \coordinate (c2) at (9,0);
  \newlength{\smallercircle}

  \foreach \i / \j [count=\ino] in {2cm/Some text along the path, 1.25cm/Some more text along another path, 0.75cm/ratio, 0.4cm/cxvzxcv}
    {
      \pgfmathsetmacro{\colmixer}{mod(10*\ino,100)}%
      \path [draw, fill=red!\colmixer] (c1) ++(0,-\i) arc (270:-90:\i);
      \ifnum\ino<4
        \setlength{\smallercircle}{\i}
        \addtolength{\smallercircle}{-7.5pt}
        \path [decoration={text along path, text={\j}, text align=center, reverse path}, decorate] (c1) ++(0,-\smallercircle) arc (-90:270:\smallercircle);
      \fi
    }

  \foreach \i / \j [count=\ino] in {4.4cm/sdfsf, 3.6cm/sfdsfd, 3.2cm/dfsdfsd, 2.8cm/dfsdfsd, 1.25cm/dfsdfad, 0.75cm/fgdsfg, 0.4cm/fsgsdgf}
    {
     \pgfmathsetmacro{\colmixer}{mod(10*\ino,100)}%
     \path [draw, fill=blue!\colmixer] (c2) ++(0,-\i) arc (-90:270:\i);
     \ifnum\ino<7
       \setlength{\smallercircle}{\i}
       \addtolength{\smallercircle}{-7.5pt}
       \path [decoration={text along path, text={\j}, text align=center, reverse path}, decorate] (c2) ++(0,-\smallercircle) arc (-90:270:\smallercircle);
     \fi
    }

  \draw [-Implies, line width=3pt] ($(c1)!1/3!(c2)$) -- ($(c1)!2/3!(c2)$);

\end{tikzpicture}
\end{document}

text inside the circles

An alternative method would be to use text effects along path rather than text along path and to specify the anchor of each character as north. This would avoid the need to specify the height of the text and avoid the need for a second path. However, I could not make this work and I could not easily figure out why so I used this method instead. Apart from the fact that I could make it work (which may just be my lack of skill with the other text decoration), the advantage of this method is that you should have fewer problems with characters overlapping, something which would be likely with the other method.

10
  • Thank you very much, this is a very good solution. Please answer one small question, how to place text on the top of the circle instead on the right hand side? Thanks once again !
    – New User
    Aug 16, 2014 at 0:02
  • 1
    The most straightforward way is to use arc instead of circle. Otherwise you need to figure out how far along the path the text should begin which is no fun.
    – cfr
    Aug 16, 2014 at 0:09
  • @NewUser Please see my updated code but note that skpblack's answer also uses the arc construction (and was posted before my update).
    – cfr
    Aug 16, 2014 at 0:23
  • Thanks for the updated code, please explain what is happening here "\draw [-Implies, line width=3pt] ($(c1)!1/3!(c2)$) -- ($(c1)!2/3!(c2)$);" . I tried changing the value "1/3" to something else and the arrow moves around, but how is it getting computed? Thanks again for the updated answer.
    – New User
    Aug 16, 2014 at 0:46
  • ($(c1)!1/3!(c2)$) is the coordinate placed in the segment of line between (c1) and (c2) (i.e (0,0) and (9,0) in the example) at 1/3 of distance of (c1) and 2/3 of c2 where 1 is the lenght of this segment.
    – skpblack
    Aug 16, 2014 at 0:57
3

When I was writing an answer for this question it was flagged as duplicate.

So here is just for fun a "style only" version.

\documentclass[tikz,border=7pt]{standalone}
\tikzset{
  hello/.style={
    label={[draw,circle,xscale={1.25},minimum size=14mm+#1*21mm]center:},
    label={[red,yshift=#1*11mm]center:hello}
  }
}
\begin{document}
\begin{tikzpicture}
  \coordinate[hello/.list={0,1,2,3}];
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

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