Statistische Daten plotten, Jahre am Xticklabel PGFplot eintragen

Statistische Daten plotten, Jahre am Xticklabel PGFplot eintragen

Ich möchte diese Daten grafisch darstellen und weiß nicht, wie ich die Jahre auf der X-Achse anbringe. Ich möchte alle Jahre anzeigen, nicht 5-Jahres-Schritte.

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

ich habe im Handbuch von einer Funktion { \year.} gelesen und sie ausprobiert, aber sie hat nicht funktioniert. Danke

Antwort1

Sie brauchen dateplotdafür nichts. Verwenden Sie einfach xtck=datazusammen mit

xticklabel style=
{/pgf/number format/1000 sep=,rotate=60,anchor=east,font=\scriptsize},

Hier ist der vollständige Code:

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

Bildbeschreibung hier eingeben

verwandte Informationen