以下代码是@user121799修改后的答案TikZ:绘制轮廓线。不同之处在于我axis x line = middle, axis y line = middle
在第一行环境中axis
添加了
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.16}
\begin{document}
\begin{tikzpicture} \begin{axis}[
axis x line = middle, axis y line = middle,
title={$x^2-x\,y$},
enlarge x limits,
view={0}{90},
xlabel=$x$, ylabel=$y$,
small,
]
\addplot3[domain=-3:3,
domain y=-3:3,
contour gnuplot={levels={-1,1},labels=false},
thick,samples=50,samples y=50,
] {x^2-x*y};
\end{axis}
\end{tikzpicture}
\end{document}
当我运行时,刻度标签不再显示。是什么原因造成的?
答案1
替换axis x line = middle, axis y line = middle,
为axis lines = middle,
。(我无法解释为什么您的版本不起作用。)
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.16}
\begin{document}
\begin{tikzpicture} \begin{axis}[
axis lines = middle,
title={$x^2-x\,y$},
enlarge x limits,
view={0}{90},
xlabel=$x$, ylabel=$y$,
small,
]
\addplot3[domain=-3:3,
domain y=-3:3,
contour gnuplot={levels={-1,1},labels=false},
thick,samples=50,samples y=50,
] {x^2-x*y};
\end{axis}
\end{tikzpicture}
\end{document}