如何减小轴上显示的数字的字体大小?

如何减小轴上显示的数字的字体大小?

有人知道我该如何减小轴上显示的数字的字体大小吗?现在,轴上的数字看起来有点乱,所以我想减小数字的字体大小,使它们看起来更整洁。

enter image description here

\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 sepx 轴上的年份

xticklabel style={/pgf/number format/1000 sep={}}

enter image description here

代码:

\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}

相关内容