是否可以将单个 x 刻度标签向右移动?
我创建了一个箱线图,并将 x 刻度设置在重要位置(下须、中位数)。由于一些点靠得很近,一些相应的 x 刻度标签重合。
现在我想将重叠的 x 刻度标签向右移动,以便所有标签都清晰易读。(我知道将标签旋转 45° 是一种可行的解决方案,但我更喜欢水平标签。)
以下是一个小例子:
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[ansinew]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz,pgf}
\usepackage{pgfplots}
\usepackage{float}
\usepgfplotslibrary{dateplot, statistics, groupplots}
\pgfplotsset{
compat=newest,
every axis/.append style={
tick label style={font=\tiny},
title style={font=\tiny}}}
\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\begin{axis}[
y tick label style={%
/pgf/number format/set thousands separator={\,},%
/pgf/number format/use comma%
},
x tick label style={%
/pgf/number format/set thousands separator={\,},%
/pgf/number format/use comma,%
align=center%
},
/pgfplots/xtick pos=left,
/pgfplots/ytick pos=left,
/pgfplots/xtick align=center,
/pgfplots/ytick align=center,
ytick=\empty,
ymin=0.5,
ymax=1.5,
width=9cm,
y=1.5cm,
xtick={2,4.5,5,7.5,9},
xticklabels={00:10:00,00:20:00,00:30:00,01:00:00,01:20:00},
]
\addplot[
boxplot prepared={
median=5,
upper quartile=7.5,
lower quartile=4.5,
upper whisker=9,
lower whisker=2,
box extend=0.5,
whisker extend=0.25,
every median/.style={black, thick}
},
] coordinates {};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}