3

I'm wondering how getting started to type this Impulse response vs. pole location map in Tikz.

ImG

it is very similar to the Poincaré-Diagram at:

http://www.texample.net/tikz/examples/poincare/

someone can type an example to get started?

Thanks!! :)

3

Here is an example. The smaller graphs are defined as pic and are placed near the poles. The positioning of the graph with repect to pole can be adjusted with the xshift and yshift keys of scope while defining scope.

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}

\tikzset{
pole/.style={blue},
grapha/.pic={
\begin{scope}[scale=0.3,xshift=-2cm, yshift=-4cm]
\draw[fill=gray!30] (-0.4,-0.4) rectangle ++(4,3);
\draw[->] (-0.4,0) -- ++(3.8,0)node[above]{$t$}; % axis
\draw[->] (0,-0.4) -- ++(0,2.8)node[right]{};
\draw[thick,domain=0:2.5]    plot (\x,{0.3*\x*\x});
\end{scope}
},
graphb/.pic={
\begin{scope}[scale=0.3,xshift=-2cm, yshift=3cm]
\draw[fill=gray!30] (-0.4,-1.5) rectangle ++(4,3);
\draw[->] (-0.4,0) -- ++(3.8,0)node[above]{$t$}; % axis
\draw[->] (0,-1.5) -- ++(0,2.8)node[right]{};
\draw[thick,domain=0:2.5]    plot (\x,{cos(8*\x r)});
\end{scope}
},
}

\begin{document}
\begin{tikzpicture}[>=stealth]
\draw[->] (-5,0) -- ++(10,0)node[below]{$Re(\sigma)$}; % axis
\draw[->] (0,-5) -- ++(0,10)node[right]{$Im(\sigma)$};

% poles
\node[pole] (a) at (3,0){$\times$};
\node[pole] (b) at (0,3){$\times$};

%
\draw pic  at (a) {grapha};
\draw pic  at (b) {graphb};

\end{tikzpicture}
\end{document}

enter image description here

  • This seems like a great place to start for the OP!. If I were to make one small suggestion is that the part \draw[fill=gray!30] (-0.4,-1.5) rectangle ++(4,3); repeats itself in every graph, and could fit nicely into its own style =) Similarly with \draw[->] (-0.4,0) -- ++(3.8,0)node[above]{$t$}; % axis \draw[->] (0,-1.5) -- ++(0,2.8)node[right]{}; as there only seem to be two variations to there the x-axis is placed =) Great answer again! – N3buchadnezzar Oct 20 '19 at 13:14
  • Nice!! Thank you very mich :) Tikz is Great – adaptive Oct 20 '19 at 13:18
3

This is based on this answer, where a similar problem was solved. You can add the function to the pic, e.g.

\path pic{graph={cos(1440*\t)*0.4*(1+0.1*\t)}};

i.e. you do not need to define a pic for each different graph. This will draw a plot of the function cos(1440*\t)*0.4*(1+0.1*\t) in the domain 0:0.9 (which I guessed from your screen shot). Obviously, \t is the variable of the function. By default, the mini axis will fit the plot and the additional point (0,0). If you want to extend the axis, you need to add extra points, e.g.

\path pic[graph/extra points={(0,0) (0,1)}]{graph={0.5+0.1*\t}};

make the axis to extend further upwards. For your convenience I also add a xmark for the crosses. Here is some complete example:

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{backgrounds,shapes.misc}
\usepackage{amsmath}
\DeclareMathOperator{\re}{Re}
\DeclareMathOperator{\im}{Im}
\begin{document}
\begin{tikzpicture}[pics/graph/.style={code={
    \begin{scope}[local bounding box=temp]
    \draw[thick]      plot[variable=\t,domain=0:0.9,samples=101,smooth] 
     ({\t-0.5},{#1});
     \edef\temp{\noexpand\path \pgfkeysvalueof{/tikz/graph/extra points};}
     \temp
    \end{scope}
    \begin{scope}[on background layer]
    \draw[fill=gray!30] ([xshift=-2mm,yshift=-3mm]temp.south west)
    rectangle ([xshift=2mm,yshift=2mm]temp.north east);
    \draw[-stealth] ([yshift=-1mm]temp.south west) -- 
    ([yshift=1mm]temp.north west);
    \draw[-stealth] (-0.6,0) -- (0.5,0)node[below,scale=0.7]{$t$};
    \end{scope}
    }},/tikz/graph/extra points/.initial={(0,0)},
    xmark/.style={cross out,minimum size=1ex,node contents={},draw=cyan!70!blue}]
  \draw[-stealth] (-5,0) -- (5,0) node[below]{$\re(\sigma)$};
  \draw[-stealth] (0,-2) -- (0,5) node[right] {$\im(j\omega)$};
  \path (0,3) node[xmark]  ++ (0,1) pic{graph={cos(1440*\t)*0.4*(1+0.1*\t)}}
  (1,2.8)  node[xmark]  ++ (1,0.5) pic{graph={cos(1440*\t)*0.4*(1+0.1*\t)}}
  (2.2,0) node[xmark] ++ (0,0.6) pic[graph/extra points={(0,0) (0,1)}]{graph={0.5+0.1*\t}};
\end{tikzpicture}
\end{document}

enter image description here

Remarks:

  1. It appears more natural to produce the inlay plots with pgfplots. However, it is nontrivial to make the axis very small. The predefined tiny axis is still 4cm wide. One could make it work (and place the axes with at=(x,y)), but this would be quite a hack.
  2. Instead of a pic one could also use a path picture, as illustrated here. However, this is also not without drawbacks since adding a node inside a path picture is not really supported.

For these reasons I suggest to use a pic, even though the lack of anchors makes the placement less intuitive. (One can add the usual anchors to a pic by making it the only element of a TikZ matrix. I am wondering if anyone has thought of copying the relevant part from tikz.code.tex to "nodify" pics.)

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.