9

I started with this picture 3 days ago, now I got stuck. In the code bellow I need to make following (see enclosed hand drawn plot).

*a) the red line (same function plotted for x=0)

b) axis arrows should be longer and shorter (see picture enter image description here), but the graph proportion should stay the same. This is the reason fot the used equivalent axis mins and max, because for other ratios, poles tops were deformed and say ugly.

c) on the plane for z=0, I need to plot 2D arc. I would be grateful for any 2D object on the (complex) plane, so one can easily get another, not just arc*

Here is what I have done so far (please note that the goal is to use for it just LaTeX - compilation time is quite long)

    \documentclass[border=1cm]{standalone}
    \usepackage{tikz}
    \usepackage{pgfplots}
    \usetikzlibrary{calc}
    \pgfplotsset{compat=newest}% <- set a compat!! (current version is 1.14)
%%%%%%%
\pgfkeys{/pgf/declare function={argsinh(\x) = ln(\x + sqrt(\x^2+1));}}
\pgfkeys{/pgf/declare function={argcosh(\x) = ln(x + sqrt(-1 + x)*sqrt(1 + x));}}
\pgfkeys{/pgf/declare function={H(\x,\y) = .125297/(sqrt((x^4-6*x^2*y^2+y^4+.581580*x^3-1.744740*x*y^2+1.169118*x^2-1.169118*y^2+.404768*x+.176987)^2+(4*x^3*y-4*x*y^3+1.744740*x^2*y-.581580*y^3+2.338236*x*y+.404768*y)^2));}}





\begin{document}

\begin{tikzpicture}
    \begin{axis}[
    axis lines=middle, axis on top, 
    view={60}{45},  
    xmin=-0.75,
    xmax=0.75,
    ymin=0,
    ymax=1.5,       
    miter limit=1]



    %%pole position as projection
    \addplot3[dotted,black] coordinates {
        (0,.946484433184241,0)
        (-.851703985681571e-1,.946484433184241,0)
        (-.851703985681571e-1,0,0)
    };

    %%pole position as projection
    \addplot3[dotted,black] coordinates {
        (0,.392046688799926,0)
        (-.205619531335967,.392046688799926,0)
        (-.205619531335967,0,0)
    };  


    %%pole position as projection / vertical lines
    \addplot3[dotted,black] coordinates {        
        (-.205619531335967,.392046688799926,0)
        (-.205619531335967,.392046688799926,1.5)
    };



    \addplot3[
        smooth,     
        surf,
        faceted color=black,
        line width=0.01pt,      
        fill=white,                             
        domain=-0.75:0,
        y domain = 0:1.5,
        samples = 30,
        samples y = 40,
        restrict z to domain*=0:1.5]        
        {H(\x,\y)};

    \addplot3[
        smooth,
        surf,
        faceted color=black,
        line width=0.01pt,      
        fill=white,                             
        domain=-0.4:0,
        y domain = 0:1.2,
        samples = 30,
        samples y = 50,             
        restrict z to domain*=0:1.5]        
        {H(\x,\y)};

    %%pole position as projection / vertical lines
    \addplot3[dotted,black] coordinates {        
        (-.851703985681571e-1,.946484433184241,0)
        (-.851703985681571e-1,.946484433184241,0.85)         
    };  





    \end{axis}
\end{tikzpicture}



\end{document}
8
  • For the red line, simply add a 3d line plot with the correct coordinates:

    \addplot3[domain=0:1.5,samples=50, samples y = 0, red] ({0},{x},{H(0,x)});
    

    You will need to correct the H function definitions to use \x and \y instead of x and y:

    \pgfkeys{/pgf/declare function={argsinh(\x) = ln(\x + sqrt(\x^2+1));}}
    \pgfkeys{/pgf/declare function={argcosh(\x) = ln(\x + sqrt(-1 + \x)*sqrt(1 + \x));}}
    \pgfkeys{/pgf/declare function={H(\x,\y) = .125297/(sqrt((\x^4-6*\x^2*\y^2+\y^4+.581580*\x^3-1.744740*\x*\y^2+1.169118*\x^2-1.169118*\y^2+.404768*\x+.176987)^2+(4*\x^3*\y-4*\x*\y^3+1.744740*\x^2*\y-.581580*\y^3+2.338236*\x*\y+.404768*\y)^2));}}
    
  • To force a uniform scaling on the different axis, you can use the axis equal image key on the axis environment. With this key set, you can use xmin, xmax, etc.. to set the range of the axis. You will want to use the width key to adjust the final width of the plot.

  • pgfplots automatically communicates its coordinate system transformations to TikZ, so you can use the classical TikZ commands to draw on the plot. For instance,

    \draw[black, thin] (-.851703985681571e-1,.946484433184241,0) circle [radius=0.04];
    

    will draw a circle on the (xy) plane at the given position with given radius.

rendering

  • Now I would like to ask about plotting the same and using zmode=log in axis environemnt while axis equal image key is in use as well. I got weird plot. Please, how would you fix it? – Jan Filip Jul 30 '17 at 11:53
6

Here is the final result. It's clear, that two pole plot works better. I thought it would be nice to share result.

enter image description here

Code for two pole wersion:

\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}% loads also tikz
\usetikzlibrary{calc}
\pgfplotsset{compat=newest}%set a compat!!
%%%%%%% 
\pgfkeys{/pgf/declare function={argsinh(\x) = ln(\x + sqrt(\x^2+1));}}
\pgfkeys{/pgf/declare function={argcosh(\x) = ln(\x + sqrt(-1 + \x)*sqrt(1 + \x));}}
%%4th order normed low pass, Chebyshev
\pgfkeys{/pgf/declare function={H(\x,\y) = .125297/(sqrt((\x^4-6*\x^2*\y^2+\y^4+.581580*\x^3-1.744740*\x*\y^2+1.169118*\x^2-1.169118*\y^2+.404768*\x+.176987)^2+(4*\x^3*\y-4*\x*\y^3+1.744740*\x^2*\y-.581580*\y^3+2.338236*\x*\y+.404768*\y)^2));}}
%%5th order normed low pass, Chebyshev
\pgfkeys{/pgf/declare function={H1(\x,\y) = .62649e-1/((\x^5-10*\x^3*\y^2+5*\x*\y^4+.574500*\x^4-3.447000*\x^2*\y^2+.574500*\y^4+1.415025*\x^3-4.245075*\x*\y^2+.548937*\x^2-.548937*\y^2+.407966*\x+.62649e-1)^2+(5*\x^4*\y-10*\x^2*\y^3+\y^5+2.298000*\x^3*\y-2.298000*\x*\y^3+4.245075*\x^2*\y-1.415025*\y^3+1.097874*\x*\y+.407966*\y)^2)^(1/2);}}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
    axis lines=middle, axis on top,
    axis equal image,
    width=40cm, %%ridi velikost grafu! 
    view={50}{45},      
    xmin=-0.5,
    xmax=0.5,
    ymin=0,
    ymax=2,
    zmin=0,
    zmax=2,
    miter limit=1,   
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    xlabel=$\Sigma$,
    xlabel style={anchor=east,xshift=-5pt,at={(xticklabel* cs:.95)}},% <- position the x label
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    ylabel=$j\Omega$,
    zlabel=$\mathopen| H(j\Omega)\mathclose|$,
    zlabel style={anchor=north east},% <- position the z label
    xtick = {0,-.851703985681571e-1,-.205619531335967},
    xticklabels = {0,$\Re(s_3)$,$\Re(s_4)$},
    xticklabel style={
      yshift=6pt*(\ticknum>0?1:0)+3pt*(\ticknum>1?1:0),
      xshift=-4pt*(\ticknum>0?1:0)-2pt*(\ticknum>1?1:0)
    },
    hide obscured x ticks=false,% <- added
    %hide obscured y ticks=false,% <- added
    ytick = {.392046688799926,.946484433184241},
    yticklabels = {$\Im(s_4)$,$\Im(s_3)$},
    ztick = \empty,
    ]

    %%pole position as projection
    \addplot3[dotted,black] coordinates {
        (0,.946484433184241,0)
        (-.851703985681571e-1,.946484433184241,0)
        (-.851703985681571e-1,0,0)
    };
    %%standard circle symbol for pole
    \draw[black, thin] (-.851703985681571e-1,.946484433184241,0) circle [radius=0.03];

    %%pole position as projection
    \addplot3[dotted,black] coordinates {
        (0,.392046688799926,0)
        (-.205619531335967,.392046688799926,0)
        (-.205619531335967,0,0)
    };  
    %%standard circle symbol for pole
    \draw[black, thin] (-.205619531335967,.392046688799926,0) circle [radius=0.03];

    %%pole position as projection / vertical lines
    \addplot3[dotted,black] coordinates {        
        (-.205619531335967,.392046688799926,0)
        (-.205619531335967,.392046688799926,1.5)
    };

    \addplot3[
        smooth,
        surf,
        faceted color=black,
        line width=0.1pt, 
        fill=white,
        domain=-0.75:0,
        y domain = 0:1.5,
        samples = 50,
        samples y = 50,
        restrict z to domain*=0:1.5]
        {H(\x,\y)};

    \addplot3[
        smooth,
        surf,
        faceted color=black,
        line width=0.1pt,
        fill=white,
        domain=-0.4:0,
        y domain = 0:1.2,
        samples = 40,
        samples y = 60,
        restrict z to domain*=0:1.5]
        {H(\x,\y)};

    %%pole position as projection / vertical lines
    \addplot3[dotted,black] coordinates {
        (-.851703985681571e-1,.946484433184241,0)
        (-.851703985681571e-1,.946484433184241,0.85)
    };  

    %%red characteristics
    \addplot3[domain=0:1.5,samples=70, samples y = 0, red, thick] ({0},{x},{H(0,x)});

    %%ellipse for poles: order 4, eps=1 (3dB]
    \pgfmathsetmacro{\elipseA}{sinh((1/4)*argsinh(1/1))}
    \pgfmathsetmacro{\elipseB}{cosh((1/4)*argsinh(1/1))}
    \draw[thin,dashed,blue] (0,\elipseB,0) arc (90:270:{\elipseA} and {\elipseB});
    \end{axis}

\end{tikzpicture}
\end{document}

Or alternatively (and with correct axis label) more fancy illustration used in my thesis enter image description here

\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}% loads also tikz
\usetikzlibrary{calc,math}
\pgfplotsset{compat=newest}%set a compat!!
%%%%%%% 
\pgfkeys{/pgf/declare function={argsinh(\x) = ln(\x + sqrt(\x^2+1));}}
\pgfkeys{/pgf/declare function={argcosh(\x) = ln(\x + sqrt(-1 + \x)*sqrt(1 + \x));}}
%%4th order normed low pass, Chebyshev
\pgfkeys{/pgf/declare function={H(\x,\y) = .125297/(sqrt((\x^4-6*\x^2*\y^2+\y^4+.581580*\x^3-1.744740*\x*\y^2+1.169118*\x^2-1.169118*\y^2+.404768*\x+.176987)^2+(4*\x^3*\y-4*\x*\y^3+1.744740*\x^2*\y-.581580*\y^3+2.338236*\x*\y+.404768*\y)^2));}}
%%5th order normed low pass, Chebyshev
\pgfkeys{/pgf/declare function={H1(\x,\y) = .62649e-1/((\x^5-10*\x^3*\y^2+5*\x*\y^4+.574500*\x^4-3.447000*\x^2*\y^2+.574500*\y^4+1.415025*\x^3-4.245075*\x*\y^2+.548937*\x^2-.548937*\y^2+.407966*\x+.62649e-1)^2+(5*\x^4*\y-10*\x^2*\y^3+\y^5+2.298000*\x^3*\y-2.298000*\x*\y^3+4.245075*\x^2*\y-1.415025*\y^3+1.097874*\x*\y+.407966*\y)^2)^(1/2);}}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[    
    axis lines=middle, axis on top,
    axis equal image,
    width=50cm, %%ridi velikost grafu! 
    view={50}{45},      
    xmin=-0.27,
    xmax=0.5,
    ymin=0,
    ymax=1.7,
    zmin=0,
    zmax=2,
    miter limit=1,   
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    xlabel=$\Sigma$,
    xlabel style={anchor=east,xshift=-5pt,at={(xticklabel* cs:.95)}},% <- position the x label
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    ylabel=$j\Omega$,
    zlabel=$\mathopen| H(s)\mathclose|$,
    zlabel style={anchor=north east},% <- position the z label
    xtick = {0,-.851703985681571e-1,-.205619531335967},
    xticklabels = {0,$\Re(s_3)$,$\Re(s_4)$},
    xticklabel style={
      yshift=6pt*(\ticknum>0?1:0)+3pt*(\ticknum>1?1:0),
      xshift=-4pt*(\ticknum>0?1:0)-2pt*(\ticknum>1?1:0)
    },
    hide obscured x ticks=false,% <- added
    %hide obscured y ticks=false,% <- added
    ytick = {.392046688799926,.946484433184241},
    yticklabels = {$\Im(s_4)$,$\Im(s_3)$},
    ztick = {0.34, 0.7, 1},
    zticklabels = {$\frac{1}{\sqrt{1+\varepsilon^2/k_1^2}}$,$\frac{1}{\sqrt{1+\varepsilon^2}}$,1},  
    ]

    %%pole position as projection
    \addplot3[dotted,black] coordinates {
        (0,.946484433184241,0)
        (-.851703985681571e-1,.946484433184241,0)
        (-.851703985681571e-1,0,0)
    };
    %%standard circle symbol for pole
    \draw[black, thin] (-.851703985681571e-1,.946484433184241,0) circle [radius=0.03];

    %%pole position as projection
    \addplot3[dotted,black] coordinates {
        (0,.392046688799926,0)
        (-.205619531335967,.392046688799926,0)
        (-.205619531335967,0,0)
    };  
    %%standard circle symbol for pole
    \draw[black, thin] (-.205619531335967,.392046688799926,0) circle [radius=0.03];

    %%pole position as projection / vertical lines
    \addplot3[dotted,black] coordinates {        
        (-.205619531335967,.392046688799926,0)
        (-.205619531335967,.392046688799926,1.5)
    };


\addplot3[
        smooth,
        surf,
        faceted color=gray,
        line width=0.1pt, 
        fill=white,
        domain=-0.75:0,
        y domain = 0:1.5,
        samples = 50,
        samples y = 50,
        restrict z to domain*=0:1.5]
        {H(\x,\y)};
    \addplot3[
        smooth,
        surf,
        faceted color=gray,
        line width=0.1pt,
        fill=white,
        domain=-0.4:0,
        y domain = 0:1.2,
        samples = 40,
        samples y = 60,
        restrict z to domain*=0:1.5]
        {H(\x,\y)};
    %%pole position as projection / vertical lines
    \addplot3[dotted,black] coordinates {
        (-.851703985681571e-1,.946484433184241,0)
        (-.851703985681571e-1,.946484433184241,0.85)
    };  

    %%red characteristics
    \addplot3[domain=0:1.5,samples=70, samples y = 0, red, thick] ({0},{x},{H(0,x)});

    %%ellipse for poles: order 4, eps=1 (3dB]
    \pgfmathsetmacro{\elipseA}{sinh((1/4)*argsinh(1/1))}
    \pgfmathsetmacro{\elipseB}{cosh((1/4)*argsinh(1/1))}
    \draw[thick,dashed,blue] (0,\elipseB,0) arc (90:270:{\elipseA} and {\elipseB});
    \end{axis}

\end{tikzpicture}
\end{document}
  • 1
    Sharing is caring, thanks ! Also, awesome handdrawn plotting skills ! – marsupilam Jul 29 '17 at 9:52

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.