Bei leerer Zelle keinen Punkt plotten

Tabellen und Grafiken erstellen und anordnen


kannstmasehn
Forum-Century
Forum-Century
Beiträge: 165
Registriert: Mo 5. Mai 2014, 16:55

Bei leerer Zelle keinen Punkt plotten

Beitrag von kannstmasehn »

Hallo,

ich möchte einen Plot aus einer Data schreiben lassen, jedoch ist nicht jede Spalte gleich lang, so dass die Werte des vorherigen gedruckten Punktes übernommen werden. Ich möchte jedoch, dass, wenn die Zelle leer ist, der Punkt einfach nicht ausgegeben wird. Wie kann ich das realisieren? Die Variante nur die ersten 10 Werte zu plotten ist für mich auch nicht zufriedenstellend.

Hier mein Minimalbeispiel:
\documentclass[a4paper, 11pt]{article}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest} % Makes the axis label placement prettier
\usepackage{filecontents}

\begin{document}
	
\begin{filecontents}{data.txt}
1 2 3
4 5 6
7 8 9
10 11 12
13 14 100
15 16
17 100
18 120 20
\end{filecontents}

\begin{tikzpicture}
	\begin{loglogaxis}[grid=major]
		
		\addplot [only marks] table[x index=1,y index=2] {data.txt};

	\end{loglogaxis}
\end{tikzpicture}

\end{document}
Zeilen 6 und 7 enthalten in Spalte 2 keine Werte, weshalb die Werte aus Zeile 5 übernommen werden.

Vielen Dank im Voraus.

Bartman
Forum-Meister
Forum-Meister
Beiträge: 2466
Registriert: Do 16. Jul 2009, 21:41
Wohnort: Hessische Provinz

Beitrag von Bartman »


kannstmasehn
Forum-Century
Forum-Century
Beiträge: 165
Registriert: Mo 5. Mai 2014, 16:55

Beitrag von kannstmasehn »

Danke. Funktioniert super.
\documentclass[a4paper, 11pt]{article}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest} % Makes the axis label placement prettier
\usepackage{filecontents}

\begin{document}
	
\begin{filecontents}{data.txt}
1 2 3
4 5 6
7 8 9
10 11 12
13 14 100
15 16 nan
17 100 nan
18 120 20
\end{filecontents}

\begin{tikzpicture}
	\begin{loglogaxis}[grid=major]
		
		\addplot [unbounded coords=jump,only marks] table[x index=1,y index=2] {data.txt};

	\end{loglogaxis}
\end{tikzpicture}


\end{document}

Antworten