Seite 1 von 1

Fehlerhafter Plot in TikZ (Axis-Environment)

Verfasst: Mo 30. Jul 2012, 09:37
von Flo
Hallo!
Ich versuche seit einigen Tagen einen Graphen mit TikZ in der Axis-umgebung zu Zeichnen. Die Auftragung ist doppellogarithmisch und die Daten sollen aus einer Datei gelesen werden.

Problematisch ist, dass bei der Ausgabe in PDF Teile der Kurven fehlen, insbesondere in der Umgebung von Kreuzungspunkten der Kurven. Die fehlenden Stücke erscheinen vollkommen willkürlich. Außerdem fehlen zusätzlich an diesen Stellen die Gitternetzlinien.
Ich habe bereits viele verschiedene Versuche unternommen und keine Lösung gefunden (z.B. style=solid line; sharp plot u.a.).
Hier mein Quelltext:
\documentclass{scrbook}

\usepackage{pgfplots}		
\usepackage{tikz}
\usetikzlibrary{plotmarks}

\begin{document}

\begin{figure}
	\begin{tikzpicture}
		\begin{loglogaxis}[
		log basis x=10,
		log basis y=10,
		xtick={650, 1000, 3000, 4500},
		grid=both,
		width=15.5cm,
		legend style={
		at={(0,1)},
		anchor=north west},
		xlabel={$n \ [U/min]$},
		ylabel={$P_{mech} \ [W]$},
		unbounded coords=discard
		]

		\addplot[black, mark=triangle*, fill=white, sharp plot] 
		file {./data/leistung0.txt};

		\addplot[black, mark=square*, fill=white, sharp plot]
		file {./data/leistung033.txt};

		\addplot[red, mark=*, fill=white, sharp plot]
		coordinates {
		(650,1667.66)
		(1100,5471.61)
		(1550,13634.54)
		(1900,23279.20)
		(2150,31970.94)
		};

%dieser Plot normalerweise aus Datei, hier testweise als %Koordinatenmatrix mit gleichen Punkten. Gerade bei diesem Plot tritt %das Problem auf



		%file {./data/leistung067.txt};

		\addplot[black, mark=+, sharp plot]
		file {./data/leistung100.txt};

		\addplot[black, mark=asterisk, sharp plot]
		file {./data/leistungmech5.txt};

		\addplot[black, mark=pentagon*, fill=white, sharp plot]
		file {./data/leistungmech5hydr033.txt};

		\addplot[black, mark=x, sharp plot]
		file {./data/leistungmech10.txt};

		\addplot[black, mark=oplus*, fill=white, sharp plot]
		file {./data/leistungmech10hydr033.txt};

		%\addplot[color=black, mark=otimes*, fill=white, style=solid]
		%file {./data/motorleistung.txt};

		\legend{leistung0, leistung033, leistung067, leistung100, leistungmech5, leistungmech5hydr033, 				leistungmech10, leistungmech10hydr033, Vollgaskennlinie Motor}




		\end{loglogaxis}
	\end{tikzpicture}

\caption{Kennlinienfeld Leistung}
\label{leistung}

\end{figure}


Achja, ich benutze MikTex 2.9.
Danke schonmal für eure Hilfe!

Verfasst: Mo 30. Jul 2012, 12:24
von Mac-Cherony
Hallo Flo,

hast du ein lauffähiges Minimalbeispiel in dem dein Problem ersichtlich wird? Dein angegebenes Beispiel gibt den richtigen Plot aus. Natürlich ohne die Plots deren Daten aus der nicht vorhandenen Textdatei kommen.
Ist das Datenformat innerhalb deiner txt eventuell nicht konsistent?

Gruß Mac-Cherony

Verfasst: Sa 4. Aug 2012, 22:48
von Flo
Hallo!
Nach langer Zeit habe ich endlich die Punkte aus den Daten als \addplot coordinates rausgeschrieben und den Quelltext des Problems aus dem Kontext rausgezogen. Der folgende Code ist komplett lauffähig und das Problem tritt noch immer auf :(
Ich hoffe jemand kennt da eine Lösung.
Danke schonmal!
\documentclass{scrbook}

\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{plotmarks}

\begin{document}

\begin{figure}
\begin{tikzpicture}
\begin{loglogaxis}[
log basis x=10,
log basis y=10,
xtick={650, 1000, 3000, 4500},
grid=both,
width=15.5cm,
legend style={
at={(0,1)},
anchor=north west},
xlabel={$n \ [U/min]$},
ylabel={$P_{mech} \ [W]$},
unbounded coords=discard
]

\addplot[black, mark=triangle*, fill=white, sharp plot]
coordinates {
(700,733.04)
(1200,1319.47)
(2750,3455.75)
(3650,5160.07)
(4500,7539.82)
};

%file {./data/leistung0.txt};

\addplot[black, mark=square*, fill=white, sharp plot]
coordinates {
(650,1429.42)
(1150,5118.18)
(1600,11728.61)
(2000,20943.95)
(2500,36651.91)
};


%file {./data/leistung033.txt};

\addplot[red, mark=*, fill=white, sharp plot] 
%als rot geplottet, da hier das problem am stärksten bemerkbar wird
coordinates {
(650,1667.66)
(1100,5471.61)
(1550,13634.54)
(1900,23279.20)
(2150,31970.94)
};

%dieser Plot normalerweise aus Datei, hier testweise als %Koordinatenmatrix mit gleichen Punkten. Gerade bei diesem Plot tritt %das Problem auf



%file {./data/leistung067.txt};

\addplot[black, mark=+, sharp plot]
coordinates {
(650,1769.76)
(1150,6563.31)
(1700,17802.36)
(2000,28169.61)
(2050,30483.92)
};

%file {./data/leistung100.txt};

\addplot[black, mark=asterisk, sharp plot]
coordinates {
(700,659.73)
(1100,1094.32)
(2000,2303.83)
(3500,4581.49)
(4000,6073.75)
};

%file {./data/leistungmech5.txt};

\addplot[black, mark=pentagon*, fill=white, sharp plot]
coordinates {
(700,1502.73)
(1100,4377.29)
(1800,15456.64)
(2200,26839.67)
(2450,34892.62)
};

%file {./data/leistungmech5hydr033.txt};

\addplot[black, mark=x, sharp plot]
coordinates {
(700,1026.25)
(1100,1612.68)
(2300,4094.54)
(3350,6314.60)
(4250,9568.77)
};

%file {./data/leistungmech10.txt};

\addplot[black, mark=oplus*, fill=white, sharp plot]
coordinates {
(625,1570.80)
(1200,5906.19)
(1700,14063.86)
(2300,30106.93)
(2450,35149.19)
};

%file {./data/leistungmech10hydr033.txt};

%\addplot[color=black, mark=otimes*, fill=white, style=solid]
%file {./data/motorleistung.txt};

\legend{leistung0, leistung033, leistung067, leistung100, leistungmech5, leistungmech5hydr033, leistungmech10, leistungmech10hydr033, Vollgaskennlinie Motor}


\end{loglogaxis}
\end{tikzpicture}

\caption{Kennlinienfeld Leistung}
\label{leistung}

\end{figure} 

\end{document}


Verfasst: Sa 4. Aug 2012, 23:08
von feuersaenger
Hallo Flo,

hat es einen besonderen Grund, dass Du 'fill=white' bei ganz vielen dieser Plots drin hast?

Wenn man das rausnimmt, klappt es naemlich (vergleiche bspw. auch mit 'fill=blue').

Mit liebem Gruss

Christian

Verfasst: Di 7. Aug 2012, 15:52
von Flo
Danke für die schnelle Hilfe. Der fill-Befehl sollte lediglich die Plotmarks weiß ausfüllen. Habe diesen aus dem \draw-Befehl. Falls jemanden der korrekte Quelltext interessiert, hab ich ihn angefügt.
Viele Grüße
Flo
\documentclass{scrbook}

\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{plotmarks}

\begin{document}

\begin{figure}
\tikzset{every mark/.append style={fill=white}}
\begin{tikzpicture}
\begin{loglogaxis}[
log basis x=10,
log basis y=10,
xtick={650, 1000, 3000, 4500},
grid=both,
width=15.5cm,
legend style={
at={(0,1)},
anchor=north west},
xlabel={$n \ [U/min]$},
ylabel={$P_{mech} \ [W]$},
unbounded coords=discard
]

\addplot[black, mark=triangle*, sharp plot]
coordinates {
(700,733.04)
(1200,1319.47)
(2750,3455.75)
(3650,5160.07)
(4500,7539.82)
};

%file {./data/leistung0.txt};

\addplot[black, mark=square*, sharp plot]
coordinates {
(650,1429.42)
(1150,5118.18)
(1600,11728.61)
(2000,20943.95)
(2500,36651.91)
};


%file {./data/leistung033.txt};

\addplot[red, mark=*, sharp plot]
coordinates {
(650,1667.66)
(1100,5471.61)
(1550,13634.54)
(1900,23279.20)
(2150,31970.94)
};

%dieser Plot normalerweise aus Datei, hier testweise als %Koordinatenmatrix mit gleichen Punkten. Gerade bei diesem Plot tritt %das Problem auf



%file {./data/leistung067.txt};

\addplot[black, mark=+, sharp plot]
coordinates {
(650,1769.76)
(1150,6563.31)
(1700,17802.36)
(2000,28169.61)
(2050,30483.92)
};

%file {./data/leistung100.txt};

\addplot[black, mark=asterisk, sharp plot]
coordinates {
(700,659.73)
(1100,1094.32)
(2000,2303.83)
(3500,4581.49)
(4000,6073.75)
};

%file {./data/leistungmech5.txt};

\addplot[black, mark=pentagon*, sharp plot]
coordinates {
(700,1502.73)
(1100,4377.29)
(1800,15456.64)
(2200,26839.67)
(2450,34892.62)
};

%file {./data/leistungmech5hydr033.txt};

\addplot[black, mark=x, sharp plot]
coordinates {
(700,1026.25)
(1100,1612.68)
(2300,4094.54)
(3350,6314.60)
(4250,9568.77)
};

%file {./data/leistungmech10.txt};

\addplot[black, mark=oplus*, sharp plot]
coordinates {
(625,1570.80)
(1200,5906.19)
(1700,14063.86)
(2300,30106.93)
(2450,35149.19)
};

%file {./data/leistungmech10hydr033.txt};

%\addplot[color=black, mark=otimes*, fill=white, style=solid]
%file {./data/motorleistung.txt};

\legend{leistung0, leistung033, leistung067, leistung100, leistungmech5, leistungmech5hydr033, leistungmech10, leistungmech10hydr033, Vollgaskennlinie Motor}




\end{loglogaxis}
\end{tikzpicture}

\caption{Kennlinienfeld Leistung}
\label{leistung}

\end{figure} 

\end{document}


Verfasst: Di 14. Aug 2012, 19:08
von feuersaenger
Hi Flo,

freut mich, dass das geholfen hat!

Du kannst mithilfe von 'mark options' oder every mark/.style={...} (oder sowas aehnliches) die Optionen nur auf die Marker anwenden! Auswaendig weiss ic hdas gerade nicht, aber eine von den zwei Optionen findest Du bestimmt im Manual.

Mit liebem Gruss

Christian