# How to draw the figure using pgf-tikz plot or Matlab?

I want to draw the following figure using pgf-Tikz package or Matlab code (anyone):

Here I have given some names to the semi-circles and nothing else. You can put any arbitrary names.

But I need to draw such figure in complex upper half plane which are basically semi-circles related to each other in the above fashion.

Please suggest me at least approximate or nearby Pgf-Tikz code or Matlab.

Edit:

Using the following script of @SevGlav, I have got the following figure:

EDIT: a complete edition of my previous post to provide a complete and more structured example, using \foreach to create automated semi circles and all.
Now you just have to choose your radiuses into the \foreach loop, and everything is fine.

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}

\begin{tikzpicture}[scale=2,font=\footnotesize]

\tikzset{xmid/.style={inner sep=0pt,below}}

\tikzset{midarrow/.style={decoration={markings, mark=at position 0.45 with {\arrow{stealth}}},
postaction={decorate}}}

\draw (-5,0) -- (5,0);
\draw (0,0) node[xmid] {\strut $O$} -- (0,5);
\foreach \x in {1,2,3,4}
{
\draw   (\x,0.05) --++ (0,-0.1)
(-\x,0.05) --++ (0,-0.1);
}
\foreach \r [count=\i] in {0.55,0.15,0.35,0.2}
{
\coordinate (a\i) at (\i-\r,0);
\coordinate (aa\i) at (-\i+\r,0);

\draw (a\i) node[xmid] {\strut $a_{\i}$} arc    (180:0:\r) node[midway] (mm\i) {}node[xmid] {\strut $b_{\i}$};
\draw (aa\i) node[xmid] {\strut $-a_{\i}$} arc  (0:180:\r) node[midway] (m\i) {} node[xmid] {\strut $-b_{\i}$};
}

\foreach \i in {1,...,4}
{
\draw[midarrow] (m\i) arc (180:0:\i) node[pos=0.45,above] {$S^{'}_{\i}$};
}

\foreach \j [count=\i] in {5,6,7,8}
{
\node [above right] at (m\i) {$D_{\i}$};
\node [above right] at (mm\i) {$D_{\j}$};
}

\end{tikzpicture}
\end{document}


• Thanks. But I have got different picture using your code, as given in the edited question Commented Jan 19, 2021 at 8:33
• I don't understand why you experiment this bug. I copied my code into a new file and compiled it just to see if a double compilation would change anything, but it worked immediatly. It seems that every S and D nodes are agglomerated at (0,0). Did you try to copy/paste it again? Commented Jan 19, 2021 at 17:47
• Your code running nicely but the output figure is same. May be my Latex editor is old version Commented Jan 20, 2021 at 14:25

You can try use IPE, an awesome tool for who wants to draw things like that without use Tikz.

• Thanks a lot. But I am unable to use the package. How to put horizontal and vertical lines and how to put semi-circles and how to put text above the semi-circles ? Commented Jan 19, 2021 at 8:50
• It's not a package, i'ts a program like Geogebra, you can draw using the optins it givest to you. All the installation and manual you can find here: ipe.otfried.org. If you want another manual: researchgate.net/publication/… Commented Jan 19, 2021 at 18:02
• Thanks. I feel easy to use Geogebra which you suggested. Thanks for it. Is there any video tutorial to use IPE? Commented Jan 20, 2021 at 10:52
• Unfortunately no. I learned from the manual that I sent as a link here and gradually, researching a lot and always. It's a battle, but it's worth it. Commented Jan 21, 2021 at 7:31
• Not necessarily. I draw the axes, click on some corner of the screen to deselect them, draw a function and click again on some corner to deselect them and so on. In the end, I select everything, use the tool that has the shortcut "E", to stretch, hold the Shift and increase the size of everything. Commented Jan 22, 2021 at 1:17

Making all the semi-circles in a single loop. A scale factor has been included. With higher values for the scale factor, it is possible to increase the font size used for the point names along the x axis, or to prevent rotation.

\documentclass[border=5pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\def\rArray{0.5, 0.18, 0.42, 0.3}  %% semi-circles radius

\def\mScale{1.4}  %%  To adjust the sizes

\draw[-latex] (-5*\mScale,0) -- (5*\mScale,0) node[below] {$\sigma$};
\draw[-latex] (0,0) -- (0,5*\mScale) node[right] {$j \omega$};
\node at (0,-0.5) {$0$};
\foreach \i [count=\c] in \rArray{
\draw[thick] (\mScale*\c-\mScale*\i,0) node[rotate=90, left] {\footnotesize $a_{\c}$} arc (180:0:\i*\mScale) node[rotate=90, left] {\footnotesize $b_{\c}$};
\draw[thick] (-\mScale*\c+\mScale*\i,0) node[rotate=90, left] {\footnotesize $-a_{\c}$} arc (0:180:\i*\mScale) node[rotate=90, left] {\footnotesize $-b_{\c}$};
\draw[thick] (-\c*\mScale, \i*\mScale) arc (180:0:\c*\mScale);
\node at (\c*\mScale-0.9*\mScale*\i, \mScale*\i+0.2) {\footnotesize $D_\c$};
\node at (-\c*\mScale+0.9*\mScale*\i, \mScale*\i+0.2) {\footnotesize $D_\c$};
\draw (0,0) ++(0,\i*\mScale) ++(100:\c*\mScale) node [above] {$S_{\c}'$};
\draw[thick,-latex] (0,0) ++(0,\i*\mScale) ++(100:\c*\mScale)  arc (100:99:\c*\mScale);
\draw (\c*\mScale, -0.07) --+(0,0.14);
\draw (-\c*\mScale, -0.07) --+(0,0.14);
}
\end{tikzpicture}


• Thanks. Your code worked fine. But can you change the style of the footnotes a_i, b_i below the horizontal axis just like the above picture in the previous answer by @SevGlav Commented Jan 20, 2021 at 10:51
• Also can you explain what the last two lines \draw (\c*\mScale, -0.07) --+(0,0.14); \draw (-\c*\mScale, -0.07) --+(0,0.14); of code means for ? Commented Jan 20, 2021 at 11:15
• Just change node[rotate=90, left] {\footnotesize $b_{\c}$} by node[below] {\footnotesize $b_{\c}$} to avoid this rotation. Commented Jan 20, 2021 at 17:12
• The last two lines draw marks on the x axis. This solution assumes that the centers of the lower semi-circles are equally spaced from each other. If the centers of the semi-circles assume arbitrary and symmetrical positions, you must create another array with the positions of these centers, and adjust the code to take this feature into account. Commented Jan 20, 2021 at 18:31

This solution allows to place the centers of the semi circles in arbitrary, but symmetrical positions.

\documentclass[border=5pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\def\rArray{{0.4, 0.18, 0.42, 0.2}}  %% semi-circles radius
\def\cArray{{0.6,2,3,3.8}}  %% semi-circles centers

\def\mScale{2}  %%  To adjust the sizes

\pgfmathsetmacro\ax{\mScale*\rArray[3] +\mScale*\cArray[3] +0.5}
\draw[-latex] (-\ax,0) -- (\ax,0) node[below] {$\sigma$};
\draw[-latex] (0,0) -- (0,\ax) node[right] {$j \omega$};
\node at (0,-0.5) {$0$};
\foreach \x in {0,...,3}{
\pgfmathsetmacro\rs{\mScale*\rArray[\x]}
\pgfmathsetmacro\cs{\mScale*\cArray[\x]}
\draw[thick] (\cs-\rs, 0) node[below] {\footnotesize $a_{\x}$} arc (180:0:\rs) node[below] {\footnotesize $b_{\x}$};
\draw[thick] (-\cs+\rs, 0) node[below] {\footnotesize $-a_{\x}$} arc (0:180:\rs) node[below] {\footnotesize $-b_{\x}$};
\draw[thick] (-\cs, \rs) arc (180:0:\cs);
\node at (\cs-0.75*\rs, \rs+0.2) {\footnotesize $D_\x$};
\node at (-\cs+0.75*\rs, \rs+0.2) {\footnotesize $D_\x$};

\draw (0,0) ++(0,\rs) ++(110:\cs) node [above] {$S_{\x}'$};
\draw[thick,-latex] (0,0) ++(0,\rs) ++(110:\cs)  arc (110:109:\cs);
\draw (\cs, -0.07) --+(0,0.14);
\draw (-\cs, -0.07) --+(0,0.14);
}
\end{tikzpicture}
\end{document}