- 也许我没有看到明显的事实:)。
- 我想要一个
extra x tick
不旋转的。 - 法线
x ticks
必须旋转 90°。 - 我也尝试过,
extra x tick style = {rotate = -90},
但没有达到预期的效果(定位失败)。
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel = {xlabel},
ylabel = {ylabel},
xtick = {0, 5},
xticklabel style = {rotate = 90},
extra x ticks = {2.5},
extra x tick labels = {{Test}},
extra x tick style = {rotate = 0},
]
\addplot {x^2 - x +4};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
您需要定义额外的刻度标签样式。例如extra x tick style={tick label style={rotate=-90}}
:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel = {xlabel},
ylabel = {ylabel},
xtick = {0, 5},
xticklabel style = {rotate = 90},
extra x ticks = {2.5},
extra x tick labels = {Test},
extra x tick style={tick label style={rotate=-90,anchor=north}}, % defined anchor is not necessary but it doesn't harm ;-)
]
\addplot {x^2 - x +4};
\end{axis}
\end{tikzpicture}
\end{document}
答案2
您正在旋转tick
0 度 - 您想要label
像这样旋转 90 度:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel = {xlabel},
ylabel = {ylabel},
xtick = {0,5},
xticklabel style = {rotate = 90},
extra x ticks = {2.5},
extra x tick style={tick label style={rotate=-90}},
extra x tick labels = {Test},
]
\addplot {x^2 - x +4};
\end{axis}
\end{tikzpicture}
\end{document}