von esdd » Di 22. Jul 2014, 14:13
Ergänze
xtick=data,
xticklabels from table={mydata.csv}{X},
xticklabel style={rotate=90,anchor=east},
bei den axis Optionen und ändere bei den plots x=X zu
Kompletter Code:
\begin{filecontents}{mydata.csv}
X Y1 Y2 Y3 Y4
00:00.0 25 25 25 24.9
00:00.5 25 25 25 24.9
00:01.0 25.2 25.1 25.1 25
00:01.5 25.7 25.2 25.5 25.2
00:02.0 26.7 25.6 26.3 25.6
00:02.5 27.7 25.9 27.3 26.1
00:03.0 28.7 26.3 28.2 26.6
00:03.5 29.7 26.8 29.3 27.2
00:04.0 30.6 27.3 30.3 27.7
00:04.5 31.6 27.7 31.4 28.3
00:05.0 32.6 28.1 32.5 28.9
00:05.5 33.6 28.7 33.6 29.4
00:06.0 34.4 29.1 34.6 30.1
00:06.5 35.4 29.7 35.7 30.6
00:07.0 36.3 30.2 36.7 31.3
00:07.5 37.2 30.7 37.7 31.8
00:08.0 38.1 31.3 38.6 32.4
00:08.5 38.9 31.7 39.6 33
00:09.0 39.7 32.3 40.4 33.7
00:09.5 40.5 32.8 41.3 34.2
00:10.0 41.3 33.3 42.2 34.8
\end{filecontents}
\documentclass[paper=a4,parskip]{scrreprt}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\pgfplotsset{/pgf/number format/use comma}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}
\begin{axis}[width=0.6\textheight,
height=0.4\textheight,
xlabel={Zeit [mm:ss.0]},
ylabel={Temperatur[Celsius]},
ymajorgrids,
xtick=data,
xticklabels from table={mydata.csv}{X},
xticklabel style={rotate=90,anchor=east},
legend pos=outer north east,
legend cell align=left,
legend style={draw=none}]
\addplot[color=black,mark=none] table [x expr=\coordindex,y=Y1] {mydata.csv};
\addplot[color=blue,mark=none] table [x expr=\coordindex,y=Y2] {mydata.csv};
\addplot[color=red,mark=none] table [x expr=\coordindex,y=Y3] {mydata.csv};
\addplot[color=red,mark=none] table [x expr=\coordindex,y=Y4] {mydata.csv};
\legend{S1.1, S1.2, S2.1, S2.2}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
Um nur die xticklabel mit vollen Sekunden anzeigen zu lassen, fällt mir gerade nichts besseres ein als eine weitere Tabelle zu verwenden.
\begin{filecontents}{mydata.csv}
X Y1 Y2 Y3 Y4
00:00.0 25 25 25 24.9
00:00.5 25 25 25 24.9
00:01.0 25.2 25.1 25.1 25
00:01.5 25.7 25.2 25.5 25.2
00:02.0 26.7 25.6 26.3 25.6
00:02.5 27.7 25.9 27.3 26.1
00:03.0 28.7 26.3 28.2 26.6
00:03.5 29.7 26.8 29.3 27.2
00:04.0 30.6 27.3 30.3 27.7
00:04.5 31.6 27.7 31.4 28.3
00:05.0 32.6 28.1 32.5 28.9
00:05.5 33.6 28.7 33.6 29.4
00:06.0 34.4 29.1 34.6 30.1
00:06.5 35.4 29.7 35.7 30.6
00:07.0 36.3 30.2 36.7 31.3
00:07.5 37.2 30.7 37.7 31.8
00:08.0 38.1 31.3 38.6 32.4
00:08.5 38.9 31.7 39.6 33
00:09.0 39.7 32.3 40.4 33.7
00:09.5 40.5 32.8 41.3 34.2
00:10.0 41.3 33.3 42.2 34.8
\end{filecontents}
\begin{filecontents}{mylabel.csv}
X
00:00.0
00:01.0
00:02.0
00:03.0
00:04.0
00:05.0
00:06.0
00:07.0
00:08.0
00:09.0
00:10.0
\end{filecontents}
\documentclass[paper=a4,parskip]{scrreprt}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\pgfplotsset{/pgf/number format/use comma}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}
\begin{axis}[width=0.6\textheight,
height=0.4\textheight,
xlabel={Zeit [mm:ss.0]},
ylabel={Temperatur[Celsius]},
ymajorgrids,
xtick={0,2,...,100},
xticklabels from table={mylabel.csv}{X},,
xticklabel style={rotate=90,anchor=east},
legend pos=outer north east,
legend cell align=left,
legend style={draw=none}]
\addplot[color=black,mark=none] table [x expr=\coordindex,y=Y1] {mydata.csv};
\addplot[color=blue,mark=none] table [x expr=\coordindex,y=Y2] {mydata.csv};
\addplot[color=red,mark=none] table [x expr=\coordindex,y=Y3] {mydata.csv};
\addplot[color=red,mark=none] table [x expr=\coordindex,y=Y4] {mydata.csv};
\legend{S1.1, S1.2, S2.1, S2.2}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
Gruß
Elke
Ergänze
[code] xtick=data,
xticklabels from table={mydata.csv}{X},
xticklabel style={rotate=90,anchor=east},[/code]
bei den axis Optionen und ändere bei den plots x=X zu
[code]x expr=\coordindex[/code]
Kompletter Code:
[code]\begin{filecontents}{mydata.csv}
X Y1 Y2 Y3 Y4
00:00.0 25 25 25 24.9
00:00.5 25 25 25 24.9
00:01.0 25.2 25.1 25.1 25
00:01.5 25.7 25.2 25.5 25.2
00:02.0 26.7 25.6 26.3 25.6
00:02.5 27.7 25.9 27.3 26.1
00:03.0 28.7 26.3 28.2 26.6
00:03.5 29.7 26.8 29.3 27.2
00:04.0 30.6 27.3 30.3 27.7
00:04.5 31.6 27.7 31.4 28.3
00:05.0 32.6 28.1 32.5 28.9
00:05.5 33.6 28.7 33.6 29.4
00:06.0 34.4 29.1 34.6 30.1
00:06.5 35.4 29.7 35.7 30.6
00:07.0 36.3 30.2 36.7 31.3
00:07.5 37.2 30.7 37.7 31.8
00:08.0 38.1 31.3 38.6 32.4
00:08.5 38.9 31.7 39.6 33
00:09.0 39.7 32.3 40.4 33.7
00:09.5 40.5 32.8 41.3 34.2
00:10.0 41.3 33.3 42.2 34.8
\end{filecontents}
\documentclass[paper=a4,parskip]{scrreprt}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\pgfplotsset{/pgf/number format/use comma}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}
\begin{axis}[width=0.6\textheight,
height=0.4\textheight,
xlabel={Zeit [mm:ss.0]},
ylabel={Temperatur[Celsius]},
ymajorgrids,
xtick=data,
xticklabels from table={mydata.csv}{X},
xticklabel style={rotate=90,anchor=east},
legend pos=outer north east,
legend cell align=left,
legend style={draw=none}]
\addplot[color=black,mark=none] table [x expr=\coordindex,y=Y1] {mydata.csv};
\addplot[color=blue,mark=none] table [x expr=\coordindex,y=Y2] {mydata.csv};
\addplot[color=red,mark=none] table [x expr=\coordindex,y=Y3] {mydata.csv};
\addplot[color=red,mark=none] table [x expr=\coordindex,y=Y4] {mydata.csv};
\legend{S1.1, S1.2, S2.1, S2.2}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document} [/code]
Um nur die xticklabel mit vollen Sekunden anzeigen zu lassen, fällt mir gerade nichts besseres ein als eine weitere Tabelle zu verwenden.
[code]\begin{filecontents}{mydata.csv}
X Y1 Y2 Y3 Y4
00:00.0 25 25 25 24.9
00:00.5 25 25 25 24.9
00:01.0 25.2 25.1 25.1 25
00:01.5 25.7 25.2 25.5 25.2
00:02.0 26.7 25.6 26.3 25.6
00:02.5 27.7 25.9 27.3 26.1
00:03.0 28.7 26.3 28.2 26.6
00:03.5 29.7 26.8 29.3 27.2
00:04.0 30.6 27.3 30.3 27.7
00:04.5 31.6 27.7 31.4 28.3
00:05.0 32.6 28.1 32.5 28.9
00:05.5 33.6 28.7 33.6 29.4
00:06.0 34.4 29.1 34.6 30.1
00:06.5 35.4 29.7 35.7 30.6
00:07.0 36.3 30.2 36.7 31.3
00:07.5 37.2 30.7 37.7 31.8
00:08.0 38.1 31.3 38.6 32.4
00:08.5 38.9 31.7 39.6 33
00:09.0 39.7 32.3 40.4 33.7
00:09.5 40.5 32.8 41.3 34.2
00:10.0 41.3 33.3 42.2 34.8
\end{filecontents}
\begin{filecontents}{mylabel.csv}
X
00:00.0
00:01.0
00:02.0
00:03.0
00:04.0
00:05.0
00:06.0
00:07.0
00:08.0
00:09.0
00:10.0
\end{filecontents}
\documentclass[paper=a4,parskip]{scrreprt}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\pgfplotsset{/pgf/number format/use comma}
\begin{document}
\begin{figure}[htb]
\centering
\begin{tikzpicture}
\begin{axis}[width=0.6\textheight,
height=0.4\textheight,
xlabel={Zeit [mm:ss.0]},
ylabel={Temperatur[Celsius]},
ymajorgrids,
xtick={0,2,...,100},
xticklabels from table={mylabel.csv}{X},,
xticklabel style={rotate=90,anchor=east},
legend pos=outer north east,
legend cell align=left,
legend style={draw=none}]
\addplot[color=black,mark=none] table [x expr=\coordindex,y=Y1] {mydata.csv};
\addplot[color=blue,mark=none] table [x expr=\coordindex,y=Y2] {mydata.csv};
\addplot[color=red,mark=none] table [x expr=\coordindex,y=Y3] {mydata.csv};
\addplot[color=red,mark=none] table [x expr=\coordindex,y=Y4] {mydata.csv};
\legend{S1.1, S1.2, S2.1, S2.2}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
[/code]
Gruß
Elke