我对 pgfplots 可以添加到 3D 图中的轮廓线有疑问。我希望轮廓线为虚线而不是实线。我附上了一个来自 pgfplots 手册的小示例,其中我希望黑线为虚线。
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,ylabel=$y$,
enlargelimits=false,
3d box=complete
]
\addplot3[surf]
{x^2-y^2};
20
0
5
−20
0
−4 −2
0
x
2
4
−5
y
\addplot3[
contour gnuplot={contour dir=y,
draw color=red,labels=false},
y filter/.expression={-5}
] {x^2-y^2};
\addplot3[
contour gnuplot={contour dir=x,
draw color=blue,labels=false},
x filter/.expression={5}
] {x^2-y^2};
\addplot3[
contour gnuplot={contour dir=z,
draw color=black,labels=false},
z filter/.expression={25}
] {x^2-y^2};
\end{axis}
\end{tikzpicture}
答案1
用于dashed
\addplot3[
contour gnuplot={contour dir=z,
draw color=black,labels=false},
z filter/.expression={25},dashed %%<-------
] {x^2-y^2};
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,ylabel=$y$,
enlargelimits=false,
3d box=complete
]
\addplot3[surf]
{x^2-y^2};
\addplot3[
contour gnuplot={contour dir=y,
draw color=red,labels=false},
y filter/.expression={-5}
] {x^2-y^2};
\addplot3[
contour gnuplot={contour dir=x,
draw color=blue,labels=false},
x filter/.expression={5}
] {x^2-y^2};
\addplot3[
contour gnuplot={contour dir=z,
draw color=black,labels=false},
z filter/.expression={25},dashed
] {x^2-y^2};
\end{axis}
\end{tikzpicture}
\end{document}