![如何减小轴上显示的数字的字体大小?](https://linux22.com/image/329814/%E5%A6%82%E4%BD%95%E5%87%8F%E5%B0%8F%E8%BD%B4%E4%B8%8A%E6%98%BE%E7%A4%BA%E7%9A%84%E6%95%B0%E5%AD%97%E7%9A%84%E5%AD%97%E4%BD%93%E5%A4%A7%E5%B0%8F%EF%BC%9F.png)
有人知道我该如何减小轴上显示的数字的字体大小吗?现在,轴上的数字看起来有点乱,所以我想减小数字的字体大小,使它们看起来更整洁。
\pgfplotsset{width=9cm,compat=1.9,every axis label/.append style={
ylabel=Percentage of Smokers,xlabel=Year,font=\small}}
\begin{tikzpicture}
\begin{axis}[
title={Percentage of Current Smokers Among Singapore Residents Aged 18 to 69},
xlabel={Year},
ylabel={Percentage of Smokers},
xmin=1990, xmax=2015,
ymin=12, ymax=20,
xtick={1992,1998,2001,2004,2007,2010,2013},
ytick={18.3,15.2,13.8,12.6,13.6,14.3,13.3},
legend pos=north west,
ymajorgrids=true,
grid style=dashed,
]
\addplot[
color=blue,
mark=square,
]
coordinates {
(1992,18.3)(1998,15.2)(2001,13.8)(2004,12.6)(2007,13.6)(2010,14.3)(2013,13.3)
};
\end{axis}
\end{tikzpicture}
答案1
您可以使用
ticklabel style={font=\tiny}
更改刻度标签的大小。我还将删除1000 sep
x 轴上的年份
xticklabel style={/pgf/number format/1000 sep={}}
代码:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{
compat=1.9,
width=9cm,
label style={font=\small}
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={Percentage of Current Smokers Among Singapore Residents Aged 18 to 69},
xlabel={Year},
ylabel={Percentage of Smokers},
xmin=1990, xmax=2015,
ymin=12, ymax=20,
xtick={1992,1998,2001,2004,2007,2010,2013},
ytick={18.3,15.2,13.8,12.6,13.6,14.3,13.3},
ticklabel style={font=\tiny},%< - added
xticklabel style={/pgf/number format/1000 sep={}},%< - added
legend pos=north west,
ymajorgrids=true,
grid style=dashed,
]
\addplot[
color=blue,
mark=square,
]
coordinates {
(1992,18.3)(1998,15.2)(2001,13.8)(2004,12.6)(2007,13.6)(2010,14.3)(2013,13.3)
};
\end{axis}
\end{tikzpicture}
\end{document}