我使用 pgfplot 绘制了一个图,并添加了几个额外的刻度。现在我只想显示那些额外的刻度。我删除了数字,xticklabels={},
但刻度仍然存在。
以下是一个小例子:
\documentclass[paper=a4,12pt,version=last,landscape]{scrartcl}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
scale only axis,
xmin=-5 ,xmax=105,
ymin=0,ymax=10,
axis y line*=left,
axis x line*=bottom,
xlabel=,
extra x ticks={0,30,50,70,100},
extra x tick labels={{0},{30},{50},{70},{100}},
extra x tick style={color=black},
every x tick/.style={black},
xticklabels={},
]
\addplot [red] {x};
\end{axis}
\end{tikzpicture}
\end{document}
有人能帮忙吗?非常感谢 :)
答案1
自动 x 刻度被特殊值抑制\empty
:
xtick=\empty
\documentclass[paper=a4,12pt,version=last,landscape]{scrartcl}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
scale only axis,
xmin=-5 ,xmax=105,
ymin=0,ymax=10,
axis y line*=left,
axis x line*=bottom,
xlabel=,
xtick=\empty,
extra x ticks={0,30,50,70,100},
extra x tick labels={{0},{30},{50},{70},{100}},
extra x tick style={color=black},
every x tick/.style={black},
]
\addplot [red] {x};
\end{axis}
\end{tikzpicture}
\end{document}
但是:“空 x 刻度”+“额外刻度”=“x 刻度”,而不需要“额外刻度”?
此外,虚拟函数的域也发生了变化,以增强其可见性:
\documentclass[paper=a4,12pt,version=last,landscape]{scrartcl}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
scale only axis,
xmin=-5 ,xmax=105,
ymin=0,ymax=10,
axis y line*=left,
axis x line*=bottom,
xlabel=,
xtick={0, 30, 50, 70, 100},
]
\addplot[domain=0:10] [red] {x};
\end{axis}
\end{tikzpicture}
\end{document}