尽管axis on top = false
有选择,但以下 MWE 中的 0 轮廓线(即 x=0 方程线)并未出现。有解决办法吗?
\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=center, axis on top=false, domain=-2:2, y domain=-1.5:1.5,
view = {0}{90}, colorbar]
\addplot3[contour gnuplot={labels=false,
levels={-0.2, -0.1, 0, 0.1, 0.2}},
samples=100]{x*exp(-x^2-y^2))};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
根据这个答案https://tex.stackexchange.com/a/450780/263192,set layers
并on layer=axis foreground
解决了这个问题。
\documentclass[12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=center,
set layers,
domain=-2:2,
y domain=-1.5:1.5,
view = {0}{90},
colorbar
]
\addplot3[
on layer=axis foreground,
contour gnuplot={
labels=false,
levels={-0.2, -0.1, 0, 0.1, 0.2}
},
samples=100
] {x*exp(-x^2-y^2))};
\end{axis}
\end{tikzpicture}
\end{document}