1

I need an log y-axis for my 3D-plot, but somehow it seems that the generated plot is also in the negative y-range (not the axis-labels, but the y-domain). The y-domain seems to be -1:1 (in fact it is, but i thougt it should work because of the "10^y" -> y-domain=0.1:10 (see comment in the code)).

I used this post for my code: 3d surface plot with logarithmic x and y axis

Plot 1 - lin y-axis, Plot 2 - log y-axis (attempt)

enter image description here

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{tikz}

\begin{document}

\begin{figure}[h!]
\begin{tikzpicture}
\begin{axis} 
[scale = 1,
xlabel = {$\sigma$},
xmin = -10, xmax = 10,
ylabel = {$\omega$},
ymin = 0.1, ymax = 10,
zlabel={$A$},
zmin = -40, zmax = 20,
colormap/viridis]

\addplot3[
surf,
samples=40,
domain=-1:10,
domain y=0:10]
(x, y, {20*log10(1/sqrt(((1.40845*y)+(2*x*y))^2+(1+(1.40845*x)+x^2-y^2)^2))});
\end{axis}
\end{tikzpicture}
\caption{Plot 1}
\end{figure}


\begin{figure}[h!]
\begin{tikzpicture}
\begin{axis} 
[scale = 1,
xlabel = {$\sigma$},
xmin = -10, xmax = 10,
ylabel = {$\omega$},
ymin = 1e-1, ymax = 1e1,
zlabel={$A$},
zmin = -40, zmax = 20,
ymode=log,        %added ymode
colormap/viridis]

\addplot3[
surf,
samples=40,
domain=-1:10,
domain y=-1:1]    %new y-domain (10^y in the next line) 
(x, 10^y, {20*log10(1/sqrt(((1.40845*y)+(2*x*y))^2+(1+(1.40845*x)+x^2-y^2)^2))});
\end{axis}
\end{tikzpicture}
\caption{Plot 2}
\end{figure}

\end{document}

I expect something like this (Plot generated in Mathematica - with log y-axis):

enter image description here

2

I guess you thought way to complicated. Just adapt domain y according to ymin/ymax and you get the desired result ...

% used PGFPlots v1.16
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        view={50}{50},
        width=\axisdefaultwidth,
        height=5cm,
        xlabel={$\sigma$},
        xmin=-1, xmax=10,
        ylabel={$\omega$},
        ymin=1e-1, ymax=1e1,
        zlabel={$A$},
        zmin=-40, zmax=20,
        ymode=log,
        colormap/viridis,
]
        \addplot3[
            surf,
            samples=40,
            domain=-1:10,
            domain y=0.1:10,    % <-- adapted
        % (no need to use a parametric plot)
        ] {20*log10(1/sqrt(((1.40845*y)+(2*x*y))^2+(1+(1.40845*x)+x^2-y^2)^2))};
    \end{axis}
\end{tikzpicture}
\end{document}

image showing the result of above code

2

I think that if you substitute every y per 10^y in the equation you can get a more similiar result, see this:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\begin{axis} 
[scale = 1,
xlabel = {$\sigma$},
xmin = -10, xmax = 10,
ylabel = {$\omega$},
ymin = 1e-1, ymax = 1e1,
zlabel={$A$},
zmin = -40, zmax = 20,
ymode=log,        %added ymode
view={60}{45},
colormap/viridis]

\addplot3[
surf,
samples=100,
domain=-1:9,
domain y=-1:1]    %new y-domain (10^y in the next line) 
(x, 10^y, {20*log10(1/sqrt(((1.40845*(10^y))+(2*x*(10^y)))^2+(1+(1.40845*x)+x^2- 
(10^y)^2)^2))});
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

The rounded shape in the botton of the orange surface might be a Mathematica's capability to trim out the surface and make more continuous plots. Alternatively, using tikz you are able to achieve a desired shape of surface performing subtractions of other mathematical functions, like F(x,y,z)= G(x,y,z)-h(x,y,z)

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.