
我想繪製這些數據,但我不知道如何將年份放在 X 軸上,我想顯示所有年份而不是 5 年的步驟。
\begin{tikzpicture}
\begin{axis}[width=8cm,
x tick label style={
/pgf/number format/1000 sep=},
ylabel=Tonnes,
]
\addplot
coordinates {(1992,205.0)
(1993,297.0)
(1994,395.0)
(1995,1601.0)
(1996,213.0)
(1997,241.0)
(1998,203.0)
(1999,372.0)
(2004,300.26)
(2005,446.17)
(2006,530.4)
(2007,591.38)
(2008,948.04)
(2009,596.01)
(2010,768.448)
(2011,978.0)
(2012,1050.0)};
\end{axis}
\end{tikzpicture}
我在手冊上讀到了關於函數 { \year
.} 的內容,我嘗試了它,但它不起作用。謝謝
答案1
你不需要dateplot
這個。只需xtck=data
與
xticklabel style=
{/pgf/number format/1000 sep=,rotate=60,anchor=east,font=\scriptsize},
這是完整的程式碼:
\documentclass{book}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[width=8cm,
xtick=data,
xticklabel style=
{/pgf/number format/1000 sep=,rotate=60,anchor=east,font=\scriptsize},
ylabel=Tonnes,
]
\addplot
coordinates {(1992,205.0)
(1993,297.0)
(1994,395.0)
(1995,1601.0)
(1996,213.0)
(1997,241.0)
(1998,203.0)
(1999,372.0)
(2004,300.26)
(2005,446.17)
(2006,530.4)
(2007,591.38)
(2008,948.04)
(2009,596.01)
(2010,768.448)
(2011,978.0)
(2012,1050.0)};
\end{axis}
\end{tikzpicture}
\end{document}