答案1
对于普通刻度,extra y tick labels={}
将删除多余刻度的标签。对于较粗的红线,例如使用major grid style={red, very thick}
。
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ytick distance=1, % just for example
grid,
extra y ticks = {-0.5,0.5},
extra y tick labels={}, % remove labels for extra ticks
extra tick style={
major grid style={red, very thick} % for multiple settings, use a pair of braces
},
]
\addplot {2*rnd -1};
\end{axis}
\end{tikzpicture}
\end{document}