Seite 1 von 1

pgfplot x-Achse Aufteilen

Verfasst: Mo 7. Nov 2016, 10:51
von Annelise
Hallo,

ich erstelle gerade Graphen mit pgfplot und brauche eine andere Aufteilung als die normale oder logarithmische. Die Zahlen sollen immer den gleichen Abstand auf der x-Achse haben. Also z.B. die 0.25 zur 1 den gleichen Abstand wie die 91 zur 180. Habt ihr da eine Idee?
Im folgenden mein momentaner Code:
\begin{figure}[ht]
\begin{tikzpicture}
	\centering
		\begin{axis}[width=0.9\textwidth,height=0.4\textheight, legend pos=south east,
			xlabel={Hydratationsdauer in Tagen$\sqrt{t}$},
			ylabel={(Na$^2$ + K$^+$)$-$ Konzentration in mmol/l},
			xmin=0, xmax=180,
      ymin=13, ymax=13.9,
			xtick={0.25,1,2,7,28,56,91,180},
			x tick label style={/pgf/number format/1000 sep=},
			y tick label style={/pgf/number format/1000 sep=},
			ytick={{13.3},{13.6},{13.8},{13.9}},
			%extra y ticks={15, 17},
			%extra y tick labels={{15},{17}},
			extra y tick style={grid=major,
				tick label style={xshift=-1cm}},
				grid=both]
			\addplot [black,line width=1pt] table {Diagramme/schaeferph1.csv};
			\addplot [dash pattern=on 4pt off 2pt on 2pt off 1pt,line width=1pt] table {Diagramme/schaeferph2.csv};
			\addplot [dash pattern=on 2pt off 1pt on 2pt off 1pt,line width=1pt] table {Diagramme/schaeferph3.csv};
			\addplot [dash pattern=on 5pt off 2pt,line width=1pt ] table {Diagramme/schaeferph4.csv};
			\legend{%
					Referenzmischung,
					20 M.-\% SFA,
					40 M.-\% SFA,
					60 M.-\% SFA
				}
		\end{axis}
	\end{tikzpicture}
\caption{Veränderung des Natrium- und Kaliumgehalts und des pH-Wertes \cite{Sch06}}
\label{SFApH}
\end{figure}
Grüße, Annelise

Verfasst: Mo 7. Nov 2016, 11:43
von esdd
Bitte erstelle immer ein kurzes, aber lauffähiges Minimalbeispiel. Bei Dir fehlen insbesondere Daten, die geplottet werden sollen. Außerdem beim Einfügen von Code bitte den Codebutton nutzen und das Ergebnis in der Vorschau ansehen.

Du kannst eventuell symbolic x coords nutzen. Ob das möglich ist, hängt aber von Deinen Daten ab.
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
 \begin{tikzpicture} 
 \begin{axis}[width=0.9\textwidth,height=0.4\textheight, legend pos=south east, 
 xlabel={Hydratationsdauer in Tagen$\sqrt{t}$}, 
 ylabel={(Na$^2$ + K$^+$)$-$ Konzentration in mmol/l}, 
 xmin=0, xmax=180, 
 ymin=13, ymax=13.9,
 symbolic x coords={0.25,1,2,7,28,56,91,180},
 xtick={0.25,1,2,7,28,56,91,180},% Alternative, wenn im ersten Plot alle vorhanden: xtick=data
 xmin=0.25,xmax=180,
 enlarge x limits=.1,
 x tick label style={/pgf/number format/1000 sep=}, 
 y tick label style={/pgf/number format/1000 sep=}, 
 ytick={{13.3},{13.6},{13.8},{13.9}},
 ymin=13,ymax=14,% Angabe notwendig, da keine Daten vorhanden
 %extra y ticks={15, 17}, 
 %extra y tick labels={{15},{17}}, 
 extra y tick style={grid=major, 
 tick label style={xshift=-1cm}}, 
 grid=both] 
 %\addplot [black,line width=1pt] table {Diagramme/schaeferph1.csv}; 
 %\addplot [dash pattern=on 4pt off 2pt on 2pt off 1pt,line width=1pt] table {Diagramme/schaeferph2.csv}; 
 %\addplot [dash pattern=on 2pt off 1pt on 2pt off 1pt,line width=1pt] table {Diagramme/schaeferph3.csv}; 
 %\addplot [dash pattern=on 5pt off 2pt,line width=1pt ] table {Diagramme/schaeferph4.csv}; 
 %\legend{% 
 %Referenzmischung, 
 %20 M.-\% SFA, 
 %40 M.-\% SFA, 
 %60 M.-\% SFA 
 %} 
 \end{axis} 
 \end{tikzpicture} 
\end{document}

Verfasst: Mo 7. Nov 2016, 12:30
von Annelise
Vielen Dank für die erste Hilfe!
Das Mut dem Beispiel wusste ich leider noch nicht.
Ich probiere das einmal mit deinem Tipp aus. Wenn es nicht geht würde ich nochmal das komplette mit einfügen.
Vielen Dank schob mal

Verfasst: Mo 7. Nov 2016, 13:11
von Gast
Annelise hat geschrieben:Das Mut dem Beispiel wusste ich leider noch nicht.
Wichtige Hinweise (gibt es passend fast zu jedem der Foren hier).

BTW: Ich weiß, dass Tippfehler im Eifer des Gefechts gerne passieren. Mir selbst in unangenehm häufiger Zahl. Psychologisch gesehen ist es aber für Fragesteller günstig, wenn sie sich (ggf. unter Zuhilfenahme einer Rechtschreibkorrektur für den Browser) um möglichst wenige bemühen. Auch dabei ist der Vorschau-Knopf und nochmaliges sorgfältiges Durchlesen der Frage hilfreich. Das signalisiert: Ich gebe mir Mühe, weil mir meine Frage wichtig ist!

Verfasst: Mo 7. Nov 2016, 22:25
von Annelise
Vielen Dank für die Hilfe, der Ratschlag hat funktioniert!