嗨,我使用的是混合符号标记系统(科学符号+非科学符号)。因此,科学符号的指数导致某些标签错位。这是 MWE
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{filecontents}
\usepackage{tikz}
\pgfplotsset{compat=1.9, every tick label/.append style={font=\normalsize}}
\begin{filecontents}{data.dat}
Keff PCCR
48.49 1000
38.52 300
25 100
19 50
7.4 10
0.844 2
\end{filecontents}
\begin{document}
\pgfplotstableread{data.dat}{\2}
\begin{tikzpicture}
\begin{axis}[
title={Some title},
enlarge x limits=-1,
symbolic x coords={1000,300,100,50,10,2},
xlabel={X-axis},
xtick={1000,300,100,50,10,2},
xticklabels={$\mathrm{1\times10^3}$,$\mathrm{3\times10^2}$,$100$,$50$,$10$,$2$},
scaled ticks=true,
ymin=0.5, ymax=50,
ylabel={Y-axis},
]
\addplot table [x={PCCR}, y={Keff}] {\2};
\end{axis}
\end{tikzpicture}%
\end{document}
答案1
有一个选项typeset ticklabels with strut
可以对齐刻度标签。只需将其添加到axis
环境选项中即可。
% used PGFPlots v1.15
\begin{filecontents}{data.dat}
Keff PCCR
48.49 1000
38.52 300
25 100
19 50
7.4 10
0.844 2
\end{filecontents}
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.3,
}
\pgfplotstableread{data.dat}{\2}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={Some title},
ymin=0.5,
ymax=50,
ylabel={Y-axis},
xlabel={X-axis},
symbolic x coords={1000,300,100,50,10,2},
xtick=data,
xticklabels={
$1 \times 10^3$,
$3 \times 10^2$,
$100$,
$50$,
$10$,
$2$%
},
typeset ticklabels with strut, % <-- added
enlarge x limits=false, % <-- (renamed to `false' from `1')
]
\addplot table [x={PCCR}, y={Keff}] {\2};
\end{axis}
\end{tikzpicture}
\end{document}