# Tikz 3d plot transfer function

This is a follow-up question to this

I have plotted the graph with online help of different resources (code and picture attached)

Now the problems are:

It is not correcting plotting the curve in the y-z plane the red line and give this error message

Package pgfplots Error: Sorry, you can't use 'y' in this context. PGFPlots are expected to sample a line, not a mesh. Please use the [mesh] option combined with [samples y>0] and [domain y!=0:0] to indicate a twodimensional input domain.

Labels are too small and not placed properly.

If somebody can set view angles so it looks like the original picture of the book (Picture attached).

If somebody can help in that regard.

RAR


\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc,math}

\pgfkeys{/pgf/declare function={H(\x,\y) = 3*((((((\x)^2-(\y)^2+3*(\x)+2)^2+((2*\x*\y)+3*\y)^2)+2.2204e-16)^(1/2))/(((((\x)^3+5*(\x)^2-3*\x*(\y)^2+8*x-5*(\y)^2+6)^2+(3*(\x)^2*y+10*\x*\y-(\y)^3+8*y)^2)+2.2204e-16)^(1/2)));}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle, axis on top,
axis equal image,
width=50cm,
view={30}{10},
xmin=-4,
xmax=0,
ymin=-2,
ymax=2,
zmin=0,
zmax=5,
miter limit=1,
xlabel=$\sigma$,
xlabel style={anchor=east,xshift=-5pt,at={(xticklabel* cs:.95)}},
ylabel=$j\Omega$,
zlabel=$\mathopen| H(s)\mathclose|$,
zlabel style={anchor=north east},
xtick = {-3,-2,-1,0},
hide obscured x ticks=false,
ytick = {-1,0,1},
ztick = {2,4},
]

smooth,
surf,
faceted color=gray,
line width=0.1pt,
fill=white,
domain=-4:0,
y domain = -2:2,
samples = 50,
samples y = 50,
restrict z to domain*=0:5]
{H(\x,\y)};

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

\end{axis}

\end{tikzpicture}
\end{document}



I have completed everything but just one thing left. I am not able to draw the curve of function in YZ plane where X=0. I cannot understand why this line

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


giving this error

Package pgfplots Error: Sorry, you can't use 'y' in this context. PGFPlots expected to sample a line, not a mesh. Please use the [mesh] option combined with [samples y>0] and [domain y!=0:0] to indicate a twodimensional input domain.

I have searched all websites everybody syntax is working.

Basically it should follow the curve in YZ plane of H(x,y) where x=0.

if somebody can throw some light.

\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc,math}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{arrows}

\pgfplotsset{every tick label/.append style={font=\huge}}
\pgfkeys{/pgf/declare function={H(\x,\y) = 3*((((((\x)^2-(\y)^2+3*(\x)+2)^2+((2*\x*\y)+3*\y)^2)+2.2204e-16)^(1/2))/(((((\x)^3+5*(\x)^2-3*\x*(\y)^2+8*x-5*(\y)^2+6)^2+(3*(\x)^2*y+10*\x*\y-(\y)^3+8*y)^2)+2.2204e-16)^(1/2)));}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle, axis on top,
axis equal image,
axis line style={black, ultra thick},
width=50cm,
view={30}{15},
xmin=-4,
xmax=0,
ymin=-2,
ymax=2,
zmin=0,
zmax=5,
miter limit=1,
xlabel=$\sigma$,
xlabel style={font=\Huge, anchor=east,xshift=1pt,at={(xticklabel* cs:1.05)}},
ylabel style={font=\Huge, anchor=west},
ylabel=$j\Omega$,
zlabel=$\mathopen| H(s)\mathclose|$,
zlabel style={font=\Huge, anchor=north west},
xtick = {-3,-2,-1,0},
hide obscured x ticks=false,
ytick = {-1,0,1},
ztick = {2,4},
]

smooth,
surf,
faceted color=gray,
line width=0.1pt,
fill=white,
domain=-4:0,
y domain = -2:2,
samples = 50,
samples y = 50,
restrict z to domain*=0:5]
{H(\x,\y)};

(0,1,0)
(-1,1,0)
(-1,0,0)
};

(-1,1,0)
(-1,1,5)
};

(0,-1,0)
(-1,-1,0)
(-1,0,0)
} ;

(-1,-1,0)
(-1,-1,5)
};

(-3,0,0)
(-3,0,5)
};

\addplot3[black] coordinates {(-1,1,0)} node[solid, cross out,draw=black,] {};
\addplot3[black] coordinates {(-1,-1,0)} node[solid, cross out,draw=black] {};

\addplot3[black] coordinates {(-3,0,0)} node[solid, cross out,draw=black] {};

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

\end{axis}

\end{tikzpicture}
\end{document}


• Does it really make sense to set the samples y to 0. You won't get any points. What is your expected output for the red function? Sep 19 at 5:09
• It is the curve in the 3d graph which is basically the Fourier transform. i.e. I need to plot function H with values of y and having x equal to zero. So I am in plane YZ and just plot H with y varying from -2 to 2. Sep 19 at 5:13
• I can't understand the same command works in this code but not in my code. tex.stackexchange.com/questions/383343/… Sep 19 at 5:21
• I am taking of the line \addplot3[domain=0:1.5,samples=70, samples y = 0, red, thick] ({0},{x},{H(0,x)}); I used the same line in my code but its not working. Sep 19 at 5:41
• I see the code is in the answer not in the question Sep 19 at 5:47

Finally, It is done. Mistake was a typo in function so the graph is complete. This graph is to show the poles and zeros of a transfer function with poles at $s=-1+j$, $s=-1-j$ and $s=-3$. The zeros are at $s=-1$ and $s=-2$. The read curve is the Fourier transform or frequency response.

Here is the complete code

    \documentclass[border=1cm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc,math}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{arrows}

\pgfplotsset{every tick label/.append style={font=\huge}}
\pgfkeys{/pgf/declare function={H(\x,\y) = 3*((((((\x)^2-(\y)^2+3*(\x)+2)^2+((2*\x*\y)+3*\y)^2)+2.2204e-16)^(1/2))/(((((\x)^3+5*(\x)^2-3*\x*(\y)^2+8*\x-5*(\y)^2+6)^2+(3*(\x)^2*\y+10*\x*\y-(\y)^3+8*\y)^2)+2.2204e-16)^(1/2)));}}
\tikzset{cross/.style={cross out, draw=black, minimum size=2*(#1-\pgflinewidth), inner sep=0pt, outer sep=0pt},
cross/.default={1pt}}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle, axis on top,
axis equal image,
axis line style={black, ultra thick},
width=50cm,
view={40}{15},
xmin=-4,
xmax=0,
ymin=-2,
ymax=2,
zmin=0,
zmax=5,
miter limit=1,
xlabel=$\sigma$,
xlabel style={font=\Huge, anchor=east,xshift=1pt,at={(xticklabel* cs:1.05)}},
ylabel style={font=\Huge, anchor=west},
ylabel=$j\Omega$,
zlabel=$\mathopen| H(s)\mathclose|$,
zlabel style={font=\Huge, anchor=north west},
xtick = {-3,-2,-1,0},
hide obscured x ticks=false,
ytick = {-1,0,1},
ztick = {2,4},
]

smooth,
surf,
faceted color=gray,
line width=0.1pt,
fill=white,
domain=-4:0,
y domain = -2:2,
samples = 50,
samples y = 50,
restrict z to domain*=0:5]
{H(\x,\y)};

(0,1,0)
(-1,1,0)
(-1,0,0)
};

(-1,1,0)
(-1,1,5)
};

(0,-1,0)
(-1,-1,0)
(-1,0,0)
} ;

(-1,-1,0)
(-1,-1,5)
};

(-3,0,0)
(-3,0,5)
};

\addplot3[black] coordinates {(-1,1,0)} node[solid, cross=8pt,draw=black,] {};
\addplot3[black] coordinates {(-1,-1,0)} node[solid, cross=8pt,draw=black] {};

\addplot3[black] coordinates {(-3,0,0)} node[solid, cross=8pt,draw=black] {};