Seite 1 von 1

pgf plottet Liniendiagramm falsch

Verfasst: So 31. Jan 2016, 19:57
von StefanB
Hi,

irgendwie habe ich Probleme mit pgfplots, weil die Diagramme falsch sind.
\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{pgfplots}
\begin{document}
	\begin{tikzpicture}
	\begin{axis}[
	%width=0.9\textwidth,height=0.9\textheight,
	width=0.9\textwidth,
	title={über 500 gelöste Aufgaben},
	%xtick={1,2,3,4,5,6,7,8,9},
	%	x tick label style={/pgf/number format/1000 sep=},
	xlabel={Stichprobe},
	ylabel={richtige Antworten in \%},
	ymin=0, ymax=100, xmin=1, xmax=16,enlarge x limits=0.01,legend entries={Schülerin A, Schülerin B, Schülerin C, Schülerin D, Schülerin E}, legend pos=south east, line width =1.5pt]
	
	\addplot table[x=Tag, restrict x to domain=0:7,  y=A] {alleStatsf.csv};
	\addplot table[x=Tag,restrict x to domain=0:15, y=B] {alleStatsf.csv};
	\addplot table[x=Tag, restrict x to domain=0:6,y=C] {alleStatsf.csv};
	\addplot table[x=Tag, restrict x to domain=0:10,y=D] {alleStatsf.csv};
	\end{axis}
	\end{tikzpicture}
\end{document}
Im Anhang die ods-Datei, weil keine .csv erlaubt sind.

Vor allem gehts um Schülerin B...
Inhalt der Spalte:
86.1789
70
90.5405
78.5714
93.3649
91.7197
89.1566
92.5926
91.0345
92.2222
84.6154
76.9231
90.625
91.2281
98.1818
Und was rauskommt, siehe Bild

Bild

Verfasst: So 31. Jan 2016, 20:18
von Johannes_B
Die ganze Datendatei wäre besser.

Aber davon unabhängig, ist ein Liniendiagram für deine Zwecke geeignet?

Verfasst: So 31. Jan 2016, 20:22
von StefanB
Hi,

sry, Anhang hat nicht geklappt. Jetzt nochmal als xlsx und hier direkt:
Tag	A	B	C	D
1	75	86.1789	60.396	70.9677
2	67.7966	70	59.8039	53.8462
3	83.5714	90.5405	71.4286	60
4	87.3563	78.5714	73.1707	50
5	86.6667	93.3649	66.6667	72.3404
6	84.0909	91.7197	70.9677	63.4615
7	70.1754	89.1566		74.1379
8		92.5926		69.4779
9		91.0345		71.4286
10		92.2222		72
11		84.6154		
12		76.9231		
13		90.625		
14		91.2281		
15		98.1818		
Welche Art würdest du empfehlen? Soll eine Entwicklung im Zeitverlauf darstellen...

Verfasst: Mo 1. Feb 2016, 00:18
von esdd
Wenn Du Leerzeichen als Spaltentrenner verwendest, musst Du beachten, dass für pgfplots dann mehrere hintereinander stehende Leerzeichen immer noch nur ein Spaltentrenner sind. Es wird also nicht erkannt, dass die Spalte A am Ende leere Zellen enthält. Du müsstest in diesen leeren Zellen jeweils {} einfügen.

Einfacher ist es, wenn Du beim Exportieren ins csv Format statt des Leerzeichens zum Beispiel das Semikolon als Spaltentrenner nutzt:
\begin{filecontents*}{alleStatsf.csv}
Tag;A;B;C;D
1;75;86.1789;60.396;70.9677
2;67.7966;70;59.8039;53.8462
3;83.5714;90.5405;71.4286;60
4;87.3563;78.5714;73.1707;50
5;86.6667;93.3649;66.6667;72.3404
6;84.0909;91.7197;70.9677;63.4615
7;70.1754;89.1566;;74.1379
8;;92.5926;;69.4779
9;;91.0345;;71.4286
10;;92.2222;;72
11;;84.6154;;
12;;76.9231;;
13;;90.625;;
14;;91.2281;;
15;;98.1818;;
\end{filecontents*}
\documentclass[10pt,a4paper]{article} 
\usepackage[latin1]{inputenc} 
\usepackage{amsmath} 
\usepackage{amsfonts} 
\usepackage{amssymb} 
\usepackage{graphicx} 
\usepackage{pgfplots} 
\pgfplotsset{compat=1.13}
\begin{document} 
\begin{tikzpicture} 
  \begin{axis}[ 
      %width=0.9\textwidth,height=0.9\textheight, 
      width=0.9\textwidth, 
      title={über 500 gelöste Aufgaben}, 
      table/col sep=semicolon,
      xlabel={Stichprobe}, 
      ylabel={richtige Antworten in \%}, 
      ymin=0, ymax=100,
      xmin=1, xmax=16,
      enlarge x limits=0.01,
      legend entries={Schülerin A, Schülerin B, Schülerin C, Schülerin D, Schülerin E},
      legend pos=south east,
      line width =1.5pt
    ] 
    \pgfplotsinvokeforeach{1,...,4}{
      \addplot table [y index=#1]{alleStatsf.csv};
    }
  \end{axis} 
\end{tikzpicture} 
\end{document}
Bild