1

我想使用 pgfplots 绘制两个图表。这是第一个:

在此处输入图像描述

\begin{tikzpicture}
     \begin{axis}[
        xmin=-pi,
        xmax=pi,
        ymin=-pi,
        ymax=pi,
        zmin=0,
        zmax=2.5,
        xlabel={$\varkappa_x$},
        ylabel={$\varkappa_y$},
        zlabel={$\omega$},
        xtick={-pi,-pi/2,0,pi/2,pi},
        xticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$},
        ytick={-pi,-pi/2,0,pi/2,pi},
        yticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$}
        ]
        \addplot3[surf,domain=-pi:pi,samples=40]{sqrt(2*sin(deg((x+y)/2))^2+sin(deg(x/2))^2+sin(deg(y/2))^2-sqrt(4*sin(deg((x+y)/2))^4+(sin(deg(x/2))^2-sin(deg(y/2))^2)^2))};
     \end{axis}
  \end{tikzpicture}

,

这是第二个:

在此处输入图像描述

\begin{tikzpicture}
     \begin{axis}[
        xmin=-pi,
        xmax=pi,
        ymin=-pi,
        ymax=pi,
        zmin=0,
        zmax=2.5,
        xlabel={$\varkappa_x$},
        ylabel={$\varkappa_y$},
        zlabel={$\omega$},
        xtick={-pi,-pi/2,0,pi/2,pi},
        xticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$},
        ytick={-pi,-pi/2,0,pi/2,pi},
        yticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$}
        ]
        \addplot3[surf,domain=-pi:pi,samples=40]{sqrt(2*sin(deg((x+y)/2))^2+sin(deg(x/2))^2+sin(deg(y/2))^2+sqrt(4*sin(deg((x+y)/2))^4+(sin(deg(x/2))^2-sin(deg(y/2))^2)^2))};
     \end{axis}
  \end{tikzpicture}

.

当我尝试在同一轴上绘制两个图时,会发生这种情况

https://i.stack.imgur.com/susry.png

\begin{tikzpicture}
     \begin{axis}[
        xmin=-pi,
        xmax=pi,
        ymin=-pi,
        ymax=pi,
        zmin=0,
        zmax=2.5,
        xlabel={$\varkappa_x$},
        ylabel={$\varkappa_y$},
        zlabel={$\omega$},
        xtick={-pi,-pi/2,0,pi/2,pi},
        xticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$},
        ytick={-pi,-pi/2,0,pi/2,pi},
        yticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$}
        ]
        \addplot3[surf,domain=-pi:pi,samples=40]{sqrt(2*sin(deg((x+y)/2))^2+sin(deg(x/2))^2+sin(deg(y/2))^2-sqrt(4*sin(deg((x+y)/2))^4+(sin(deg(x/2))^2-sin(deg(y/2))^2)^2))};
        \addplot3[surf,domain=-pi:pi,samples=40]{sqrt(2*sin(deg((x+y)/2))^2+sin(deg(x/2))^2+sin(deg(y/2))^2+sqrt(4*sin(deg((x+y)/2))^4+(sin(deg(x/2))^2-sin(deg(y/2))^2)^2))};
     \end{axis}
  \end{tikzpicture}

,

也就是说,我的第二个图在零附近与第一个图重叠。如何使零重叠附近的第一张图与第二张图重叠?很明显,如果我改变调用 \addplot3 的顺序,那么第一个图将与第二个图在任何地方重叠。我只希望在零附近,这样图片看起来像这样正确

在此处输入图像描述

TEX 文件

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{amsmath,amssymb}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, russian]{babel}


\pgfplotsset{compat=1.9}

\begin{document}
            \begin{tikzpicture}
                \begin{axis}[
                    xmin=-pi,
                    xmax=pi,
                    ymin=-pi,
                    ymax=pi,
                    zmin=0,
                    zmax=2.5,
                    xlabel={$\varkappa_x$},
                    ylabel={$\varkappa_y$},
                    zlabel={$\omega$},
                    xtick={-pi,-pi/2,0,pi/2,pi},
                    xticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$},
                    ytick={-pi,-pi/2,0,pi/2,pi},
                    yticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$}
                    ]
                    \addplot3[surf,domain=-pi:pi,samples=35]{sqrt(2*sin(deg((x+y)/2))^2+sin(deg(x/2))^2+sin(deg(y/2))^2-sqrt(4*sin(deg((x+y)/2))^4+(sin(deg(x/2))^2-sin(deg(y/2))^2)^2))};
                    \addplot3[surf,domain=-pi:pi,samples=35]{sqrt(2*sin(deg((x+y)/2))^2+sin(deg(x/2))^2+sin(deg(y/2))^2+sqrt(4*sin(deg((x+y)/2))^4+(sin(deg(x/2))^2-sin(deg(y/2))^2)^2))};
                \end{axis}
        \end{tikzpicture}
\end{document}
4

1 回答 1

1

您可以重绘第一个函数的部分内容:

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
     \begin{axis}[
        xmin=-pi,
        xmax=pi,
        ymin=-pi,
        ymax=pi,
        zmin=0,
        zmax=2.5,
        xlabel={$\kappa_x$},
        ylabel={$\kappa_y$},
        zlabel={$\omega$},
        xtick={-pi,-pi/2,0,pi/2,pi},
        xticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$},
        ytick={-pi,-pi/2,0,pi/2,pi},
        yticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$}
        ]
        \addplot3[surf,domain=-pi:pi,samples=40]{sqrt(2*sin(deg((x+y)/2))^2+sin(deg(x/2))^2+sin(deg(y/2))^2-sqrt(4*sin(deg((x+y)/2))^4+(sin(deg(x/2))^2-sin(deg(y/2))^2)^2))};
        \addplot3[surf,domain=-pi:pi,samples=40]{sqrt(2*sin(deg((x+y)/2))^2+sin(deg(x/2))^2+sin(deg(y/2))^2+sqrt(4*sin(deg((x+y)/2))^4+(sin(deg(x/2))^2-sin(deg(y/2))^2)^2))};
        \addplot3[
          surf,
          domain=0:pi, 
          y domain=-pi:0,
          samples=20,
        ]{sqrt(2*sin(deg((x+y)/2))^2+sin(deg(x/2))^2+sin(deg(y/2))^2-sqrt(4*sin(deg((x+y)/2))^4+(sin(deg(x/2))^2-sin(deg(y/2))^2)^2))};        
     \end{axis}
  \end{tikzpicture}

\end{document}

在此处输入图像描述

于 2021-06-10T16:18:15.847 回答