# How can I make a 3D Bode plot of a function?

I'm trying to do a Bode plot in 3D for the function below, but there is no built-in function for that.

How can I do that? It would also be nice if you could use a mesh to make it easier to see.

tf = s^2/(s^2 + 2 s + 5)


The shape of the plot may not be same as in the image, but it is a 3D object like that.

In a 2D Bode plot, s is replaced with i*w and then the magnitude/modulus of the function with frequency w is plotted. However, in a 3D plot you replace s with σ + i*w and plot the magnitude of the function with a different σ and w.

tf = s^2/(s^2 + 2 s + 5);
mag = Abs[ComplexExpand[tf /. s -> \[Sigma] + I*w]];
Plot3D[mag, {\[Sigma], -1000, 1000}, {w, -100, 100},
ScalingFunctions -> {None, None, "Log"}] • what is a Bode plot, mathematically? the wikipedia article is a bit hard to parse for someone without the EE background. (hopefully someone who already knows comes along, but in the event they don't...) – thorimur Jun 2 at 23:00
• In 2D bode plot, they replace s with i*w and then plot the magnitude/modulus of the function with frequency w. However, in 3D plot you should replace s with σ + i*w and plot the maginitude of the function with different σ and w. – anhnha Jun 2 at 23:04
• Like this?: ComplexPlot3D[tf, {s, -2 - 3 I, 0 + 3 I}, AxesLabel -> {\[Sigma], I*\[Omega]}, BoxRatios -> {2, 3, 1}] – Michael E2 Jun 2 at 23:18
• @MichaelE2 that is nice. Adding mesh may be easier to see though. How can I make a bold red curve in the intersection of the graph and the plane forming by σ = 0 and w? – anhnha Jun 2 at 23:22

May be like this.

tf = s^2/(s^2 + 2 s + 5);
mag = Abs[ComplexExpand[tf /. s -> σ + I*w]];
SetOptions[Plot3D, BoundaryStyle -> None, PlotRange -> {0, 8},
ViewPoint -> {2.54, 1.27, 1.8}, BoxRatios -> {1, 1, 1},
ClippingStyle -> Yellow];
fig1 = Plot3D[mag, {σ, -2, 0}, {w, -3, 3},
MeshFunctions -> {#3 &},
MeshShading -> {Yellow, Pink, Brown, Gray, Blue, Orange, Purple,
Cyan}, Mesh -> {20, 20, 8}];
fig2 = Plot3D[mag, {σ, -2, 1}, {w, -3, 3},
MeshFunctions -> {#1 &, #2 &}, MeshShading -> None,
PlotStyle -> None, Mesh -> {20, 20}];
fig3 = Plot3D[mag, {σ, -2, 1}, {w, -3, 3},
MeshFunctions -> {#1 &}, Mesh -> {{0}}, PlotStyle -> None,
MeshStyle -> {Thick, Red}];
Show[fig1, fig2, fig3] • the plot is very nice – anhnha Jun 3 at 3:50
Clear["Global*"]

tf = s^2/(s^2 + 2 s + 5);

Manipulate[
Show[
ComplexPlot3D[tf,
{s, -2 - 3 I, 1/4 + 3 I},
MeshFunctions -> mf,
MeshStyle -> {Black, Darker[Green]},
Mesh -> 9,
PlotPoints -> 50,
MaxRecursion -> 5,
PlotLegends -> BarLegend[Automatic,
LegendLabel -> HoldForm[Arg[tf]]],
PlotRange -> {0, 10}],
ComplexPlot3D[tf,
{s, -2 - 3 I, 1 + 3 I},
PlotStyle -> Opacity,
MeshFunctions -> {Re[#1] &},
Mesh -> {{0.}},
MeshStyle -> {{Red, Thick}}],
AxesLabel ->
(Style[#, 14, Bold] & /@ {σ, ω,
"|tf|"}),
BoxRatios -> {2, 3, 1},
SphericalRegion -> True,
` 