Seite 1 von 1

Datum in X-Achse, Pgfplot

Verfasst: Mo 16. Apr 2012, 18:24
von Krümel
Hallo,

ich habe ein Problem bei dem ich nicht weiterkomme -.-

Wie bekomme ich es hin, dass auf der X-Achse pro eingegebenem Wert ein Datum steht (also statt 1 bis 15, 1.04. bis 15.04.)?

Hoffentlich könnt ihr mir helfen!

Viele Grüße Gerrit
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5.1}
\begin{document}

\begin{tikzpicture}
	\begin{axis}
	
		\addplot coordinates{
			(1.04,5)
			(2.04,6)
			(3.04,8)
		        (4.04,4.5)
		        (5.04,9)
			(6.04,8)
			(7.04,12)
			(8.04,12)
			(9.04,11)
			(10.04,12)
			(11.04,10)
			(12.04,9.5)
			(13.04,11)
			(14.04,10)
			(15.04,13)
			(16.04,8.5)
			};
		\addlegendentry{min}
		
		\addplot coordinates{
			(1,12.5)
			(2,18.5)
			(3,14)
			(4,19.5)
			(5,17)
			(6,25.5)
			(7,25)
			(8,26)
			(9,22)
			(10,24)
			(11,22)
			(12,29)
			(13,20)
			(14,16.5)
			(15,19)
			};
		\addlegendentry{max}		
		
		
		\end{axis}
\end{tikzpicture}

\end{document}

Spezielle Bibliothek

Verfasst: Di 17. Apr 2012, 10:12
von localghost
Dafür hat pgfplots die Bibliothek »dateplot«. Es muss jedoch immer ein vollständiges Datum (YYYY-MM-DD) angegeben werden.
\documentclass[11pt,a4paper,ngerman]{article}
\usepackage[T1]{fontenc}
\usepackage{selinput}
\SelectInputMappings{
  adieresis={ä},
  germandbls={ß},
  Euro={€}
}
\usepackage{babel}
\usepackage{pgfplots}
\usepgfplotslibrary{dateplot}

\begin{document}
  \begin{tikzpicture}
    \begin{axis}[
      date coordinates in=x,
      xticklabel={\day.\month.}
    ]
      \addplot coordinates{
        (2012-04-01,5)
        (2012-04-02,6)
        (2012-04-03,8)
        (2012-04-04,4.5)
        (2012-04-05,9)
        (2012-04-06,8)
        (2012-04-07,12)
        (2012-04-08,12)
        (2012-04-09,11)
        (2012-04-10,12)
        (2012-04-11,10)
        (2012-04-12,9.5)
        (2012-04-13,11)
        (2012-04-14,10)
        (2012-04-15,13)
        (2012-04-16,8.5)
      };
      \addlegendentry{min}
     
      \addplot coordinates{
        (2012-04-01,12.5)
        (2012-04-02,18.5)
        (2012-04-03,14)
        (2012-04-04,19.5)
        (2012-04-05,17)
        (2012-04-06,25.5)
        (2012-04-07,25)
        (2012-04-08,26)
        (2012-04-09,22)
        (2012-04-10,24)
        (2012-04-11,22)
        (2012-04-12,29)
        (2012-04-13,20)
        (2012-04-14,16.5)
        (2012-04-15,19)
      };
      \addlegendentry{max}
    \end{axis}
  \end{tikzpicture}
\end{document}
Details stehen in der Anleitung.


Thorsten

Verfasst: Di 17. Apr 2012, 14:09
von Krümel
Danke :)