轴等图像键和 z log 模式

轴等图像键和 z log 模式

假设我们想绘制如下内容

在此处输入图片描述

带有代码

\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}% loads also tikz
\usetikzlibrary{calc}
\pgfplotsset{compat=newest}%set a compat!!
%%%%%%% 
\pgfkeys{/pgf/declare function={f(\x,\y)=exp(-10*(x^2+y^2));}}
\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,
    axis equal image,
    width=20cm, %%ridi velikost grafu! 
    view={50}{20},      
    xmin=-0.5,
    xmax=0.5,
    ymin=0,
    ymax=2,
    zmin=0,
    zmax=2,
    miter limit=1,   
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    xlabel=$x$,
    ylabel=$y$,
    zlabel=$z$,
    zlabel style={anchor=north east},% <- position the z label
    xtick = {0},
    xticklabels = {0},
    ytick = \empty,  
    ztick = \empty,
    ]


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

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

    \end{axis}

\end{tikzpicture}
\end{document}

如果我想zmode=log key在 axis 环境中绘制它,该怎么办?它给出了以下结果 在此处输入图片描述

如何使其表现正常?我的意思是除了 z 轴(对数缩放)之外都具有相同的缩放比例?

答案1

如您所见,所有对数 z 值都小于零。

演示

\documentclass[border=1cm]{standalone}
\usepackage{pgfplots}% loads also tikz
\usetikzlibrary{calc}
\pgfplotsset{compat=newest}%set a compat!!
%%%%%%% 
\pgfkeys{/pgf/declare function={f(\x,\y)=exp(-10*(x^2+y^2));}}
\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,
    axis equal image,
    width=20cm, %%ridi velikost grafu! 
    view={50}{20},      
    xmin=-0.5,
    xmax=0.5,
    ymin=0,
    ymax=2,
    zmin=0,
    zmax=2,
    miter limit=1,   
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    xlabel=$x$,
    ylabel=$y$,
    zlabel=$z$,
    zlabel style={anchor=north east},% <- position the z label
    xtick = {0},
    xticklabels = {0},
    ytick = \empty,  
    ztick = \empty,
    zmode=log
    ]

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

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

    \end{axis}

\end{tikzpicture}
\end{document}

相关内容