[Tex/LaTex] How to draw path of contour integral enclosing imaginary axis

decorationsnodestikz-pgf

I have practically no experience with Tikz but was able to piece together this diagram of a contour integral enclosing the imaginary axis.

enter image description here

It was produced with this code.

\documentclass[tikz,svgnames]{standalone}

\usepackage{mathtools}
\DeclareMathOperator{\im}{Im}
\DeclareMathOperator{\re}{Re}


\begin{document}
\begin{tikzpicture}[thick]
    % Axes:
    \draw [->] (-5,0) -- (5,0) node [above left]  {$\re(p_0)$};
    \draw [->] (0,-4.7) -- (0,4.7) node [below left = -1pt] {$\im(p_0)$};

    % Axes labels:
    \foreach \n in {-4,...,-1,1,2,...,4}{%
        \draw[fill] (0,\n) circle (1pt) node [right] {$i \omega_{_{\n}}$};
    }
    \draw[fill] (0,0) circle (1pt) node [above right] {0};

    % Contour line
    \draw[DarkBlue]
      (1,-4) -> (1,4) node [below right] {$C$} arc (0:180:1) (-1,4) -- (-1,-4) arc (180:360:1);

    \draw[fill] (3,2) circle (1pt) node [pin={above:poles of $h(p_0)$}] {};
    \draw[fill] (2,-2) circle (1pt) node [pin={above right:poles of $h(p_0)$}] {};

\end{tikzpicture}
\end{document}

There are a few things I'm still struggling with.

  1. I would like the two half arcs at the top and bottom to be dashed but the vertical lines connecting them to remain solid.
  2. The two pins labelling dots outside the contour with poles of h(p0) should be just one pin with lines pointing to both dots.
  3. I'd like Im(p0) to be further removed from the imaginary axis but connected by a thin line just like the pins.
  4. The contour should be decorated by a few arrows pointing in the counterclockwise direction.

Best Answer

Like this?

enter image description here

\documentclass[tikz,svgnames,border=3mm]{standalone}
\usetikzlibrary{decorations.markings, positioning}
\usepackage{mathtools}
\DeclareMathOperator{\im}{Im}
\DeclareMathOperator{\re}{Re}

\begin{document}
\begin{tikzpicture}[thick,
decoration={
markings,% switch on markings
mark=at position .75 with {\arrow{>}}}
                    ]
    % Axes:
    \draw [->] (-5,0) -- (5,0) node [above left]  {$\re(p_0)$};
    \draw [->] (0,-4.7) -- (0,4.7) node [below left = -1pt and 11mm] {$\im(p_0)$};

    % Axes labels:
    \foreach \n in {-4,...,-1,1,2,...,4}{%
        \draw[fill] (0,\n) circle (1pt) node [right] {$i \omega_{_{\n}}$};
    }
    \draw[fill] (0,0) circle (1pt) node [above right] {0};

% Contour line
\draw[DarkBlue,postaction={decorate}]   ( 1,-4) -- ( 1, 4) node [below right] {$C$};
\draw[DarkBlue,postaction={decorate}]   (-1, 4) -- (-1,-4);
\draw[DarkBlue,dashed]                  (1,4) arc (0:180:1) (-1,4)  (-1,-4) arc (180:360:1);

\draw[fill] (3, 2) circle (1pt) node[below right=2mm and 9mm] (h0) {poles of $h(p_0)$} 
            (2,-2) circle (1pt);
\draw[thin, shorten >=1mm] (h0.west) --  (3,2) (h0.south west) -- (2,-2);
\end{tikzpicture}
\end{document}

Addendum: let consider first OP comments regarding imaginary axis label:

\documentclass[tikz,svgnames,border=3mm]{standalone}
\usetikzlibrary{decorations.markings, positioning}
\usepackage{mathtools}
\DeclareMathOperator{\im}{Im}
\DeclareMathOperator{\re}{Re}

\begin{document}
\begin{tikzpicture}[thick,
decoration={
markings,% switch on markings
mark=at position .75 with {\arrow{>}}},
every pin/.append style = {pin distance=11mm, pin edge={<-,black}}% added
                    ]
% Axes:
\draw [->] (-5,0) -- (5,0) node [above left]  {$\re(p_0)$};
\draw [->] (0,-4.7) -- (0,4.7) node [below left, pin=left: $\im(p_0)$] {};% changed
% Axes labels:
\foreach \n in {-4,...,-1,1,2,...,4}{%
    \draw[fill] (0,\n) circle (1pt) node [right] {$i \omega_{_{\n}}$};
}
\draw[fill] (0,0) circle (1pt) node [above right] {0};
% Contour line
\draw[DarkBlue,postaction={decorate}]   ( 1,-4) -- ( 1, 4) node [below right] {$C$};
\draw[DarkBlue,postaction={decorate}]   (-1, 4) -- (-1,-4);
\draw[DarkBlue,dashed]                  (1,4) arc (0:180:1) (-1,4)
                                        (-1,-4) arc (180:360:1);

\draw[fill] (3, 2) circle (1pt) node[below right=2mm and 9mm] (h0) {poles of $h(p_0)$}
            (2,-2) circle (1pt);
\draw[thin, shorten >=1mm] (h0.west) --  (3,2) (h0.south west) -- (2,-2);
\end{tikzpicture}
\end{document}

enter image description here