![我怎样才能隐藏 x 轴和 y 轴上的数字但保留此图的网格?](https://linux22.com/image/361773/%E6%88%91%E6%80%8E%E6%A0%B7%E6%89%8D%E8%83%BD%E9%9A%90%E8%97%8F%20x%20%E8%BD%B4%E5%92%8C%20y%20%E8%BD%B4%E4%B8%8A%E7%9A%84%E6%95%B0%E5%AD%97%E4%BD%86%E4%BF%9D%E7%95%99%E6%AD%A4%E5%9B%BE%E7%9A%84%E7%BD%91%E6%A0%BC%EF%BC%9F.png)
我正在绘制函数图y = x^4 - 5x^2 + 4
。现在我想隐藏 x 轴和 y 轴上的数字,但保留此图的网格。我该怎么做?我的代码是
\documentclass{standalone}
\usepackage{tabvar}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{fouriernc}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[declare function={Y(\x)=\x^4 - 5 * \x^2 + 4;},
axis lines = center,
xlabel=$x$,ylabel=$y$,
domain=-2.5:2.5,
ymin=-2.5,
ymax=5.5,
xmin=-2.5,
xmax=2.5,
samples=100,xtick distance=1,
ytick distance=1,unit vector ratio*=1 1 1,
width=11cm,
grid=major,
grid style={gray!30}
]
\addplot [black, thick] {Y(x)};
%\addplot [black, mark=*,only marks,samples at={-1,1,-2,2}] {Y(x)};
\node at (axis cs:-0.25, -0.25) {$O$} ;
\end{axis}
\end{tikzpicture}
\end{document}
答案1
xticklabels={},yticklabels={}
。
将其添加到axis
选项中。这将保留刻度,但删除刻度标签。