통계 데이터를 플로팅하고 Xticklabel PGFplot에 수년을 투자합니다.

통계 데이터를 플로팅하고 Xticklabel PGFplot에 수년을 투자합니다.

이 데이터를 플롯하고 싶지만 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}

여기에 이미지 설명을 입력하세요

관련 정보