如何解决同一轴中的两个图 \addplot3 (pgfplots)
我想使用 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,pi/2,pi},xticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$},ytick={-pi,yticklabels={$-\pi$,$\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,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,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,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,$\pi$}
]
\addplot3[surf,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,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}
解决方法
您可以重绘第一个函数的部分内容:
\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,pi/2,pi},xticklabels={$-\pi$,$-\frac{\pi}{2}$,$0$,$\frac{\pi}{2}$,$\pi$},ytick={-pi,yticklabels={$-\pi$,$\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,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}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。