Anordnung von zwei Diagrammen nebeneinander (mit Komma in xaxis)

Antwort erstellen


Diese Frage dient dazu, das automatisierte Versenden von Formularen durch Spam-Bots zu verhindern.
Smilies
:D :) :( :o :shock: :? 8) :lol: :-x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:

BBCode ist eingeschaltet
[img] ist eingeschaltet
[flash] ist ausgeschaltet
[url] ist eingeschaltet
Smilies sind eingeschaltet

Die letzten Beiträge des Themas

Ich habe die Datenschutzerklärung gelesen und bin damit einverstanden.

   

Wenn du eine Datei oder mehrere Dateien anhängen möchtest, gib die Details unten ein.

Ansicht erweitern Die letzten Beiträge des Themas: Anordnung von zwei Diagrammen nebeneinander (mit Komma in xaxis)

Re: Anordnung von zwei Diagrammen nebeneinander (mit Komma in xaxis)

von Kazter » Fr 26. Aug 2022, 08:56

Mit etwas basteln, habe ich jetzt folgendes gefunden:

x label style={yshift=-3.00ex,anchor=south}

im lokalen \pgfplotsset{...}, siehe MWE.

Bin aber auch gerne für Alternativen offen ;)
\documentclass{article}
\usepackage{caption,subfig}
\usepackage{pgfplots}

\pgfplotsset{
   compat=newest,
   /pgf/number format/use comma,
}

\usepackage{siunitx}
\sisetup{
	locale = DE, 
	group-minimum-digits=4,
	per-mode=symbol-or-fraction,
  }

\begin{document}
\begin{figure}[htbp]
\centering
\pgfplotsset{
  width=0.45\textwidth, height=.25\textheight,
  typeset ticklabels with strut,
  x label style={yshift=-3.00ex,anchor=south}% <- \strut eingefügt
}
\subfloat[Caption 1 Caption 1 Caption 1 Caption 1 Caption 1]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=0,
    xmax=1.80,
    ymin=0,
    ymax=60000,
    xlabel={label x \strut\si{\cubic\metre\per\hour}},% <- \strut eingefügt
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 10000};
    \addlegendentry{\(x^3 + 3x + 10000\)}   
\end{axis}
\end{tikzpicture}
}%
\hfil
\subfloat[Caption 2 Caption 2 Caption 2 Caption 2 Caption 2]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=-25,
    xmax=25,
    ymin=0,
    ymax=100,
    xlabel={label x \strut\si{\litre\per\hour}},% <- \strut eingefügt
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 1};
    \addlegendentry{\(x^3 + 3x + 1\)}
\end{axis}
\end{tikzpicture}
}%
\caption{Caption 3}
\end{figure}

\end{document}

Re: Anordnung von zwei Diagrammen nebeneinander (mit Komma in xaxis)

von Gute*r Gȧst*in » Fr 26. Aug 2022, 08:54

Dieses Mal sind wohl nicht die ticks label, sondern die xlabel das Problem. Die haben (durch den Exponenten) eine unterschiedliche Höhe. Im Beispiel kann das recht einfach über explizite \strut gelöst werden:
\documentclass{article}
\usepackage{caption,subfig}
\usepackage{pgfplots}

\pgfplotsset{
   compat=newest,
   /pgf/number format/use comma,
}

\usepackage{siunitx}
\sisetup{
	locale = DE, 
	group-minimum-digits=4,
	per-mode=symbol-or-fraction,
  }

\begin{document}
\begin{figure}[htbp]
\centering
\pgfplotsset{
  width=0.45\textwidth, height=.25\textheight,
  typeset ticklabels with strut
}
\subfloat[Caption 1 Caption 1 Caption 1 Caption 1 Caption 1]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=0,
    xmax=1.80,
    ymin=0,
    ymax=60000,
    xlabel={label x \strut\si{\cubic\metre\per\hour}},% <- \strut eingefügt
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 10000};
    \addlegendentry{\(x^3 + 3x + 10000\)}   
\end{axis}
\end{tikzpicture}
}%
\hfil
\subfloat[Caption 2 Caption 2 Caption 2 Caption 2 Caption 2]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=-25,
    xmax=25,
    ymin=0,
    ymax=100,
    xlabel={label x \strut\si{\litre\per\hour}},% <- \strut eingefügt
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 1};
    \addlegendentry{\(x^3 + 3x + 1\)}
\end{axis}
\end{tikzpicture}
}%
\caption{Caption 3}
\end{figure}

\end{document}
Das geht häufig aber nicht immer so einfach. Sobald die beispielsweise unterschiedliche Zeilenzahl haben, wird es das so nicht mehr funktionieren.

Re: Anordnung von zwei Diagrammen nebeneinander (mit Komma in xaxis)

von Kazter » Do 25. Aug 2022, 19:59

Erst einmal vielen Dank für Eure Antworten!

Habe jetzt etwas erweitert und bekomme wieder Probleme mit der Ausrichtung, wenn ich das Paket "siunitx" einbinde...

Habe sowohl die Variante mit
typeset ticklabels with strut
als auch mit
x tick label style={text depth=0.25ex}
probiert..
\documentclass{article}
\usepackage{caption,subfig}
\usepackage{pgfplots}

\pgfplotsset{
   compat=newest,
   /pgf/number format/use comma,
}

\usepackage{siunitx}% <- eingefügt
\sisetup{
	locale = DE, 
	group-minimum-digits=4,
	per-mode=symbol-or-fraction,
  }

\begin{document}
\begin{figure}[htbp]
\centering
\pgfplotsset{
  width=0.45\textwidth, height=.25\textheight,
  typeset ticklabels with strut
}
\subfloat[Caption 1 Caption 1 Caption 1 Caption 1 Caption 1]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=0,
    xmax=1.80,
    ymin=0,
    ymax=60000,
    xlabel={label x \si{\cubic\metre\per\hour}},% <- eingefügt
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 10000};
    \addlegendentry{\(x^3 + 3x + 10000\)}   
\end{axis}
\end{tikzpicture}
}%
\hfil
\subfloat[Caption 2 Caption 2 Caption 2 Caption 2 Caption 2]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=-25,
    xmax=25,
    ymin=0,
    ymax=100,
    xlabel={label x \si{\litre\per\hour}},% <- eingefügt
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 1};
    \addlegendentry{\(x^3 + 3x + 1\)}
\end{axis}
\end{tikzpicture}
}%
\caption{Caption 3}
\end{figure}

\end{document}

Re: Anordnung von zwei Diagrammen nebeneinander (mit Komma in xaxis)

von esdd » Mo 22. Aug 2022, 01:02

Man kann auch typeset ticklabels with strut entweder global in der Präambel
\pgfplotsset{
   compat=newest,
   /pgf/number format/use comma,
   typeset ticklabels with strut
}
oder lokal verwenden:
\documentclass{article}
\usepackage{caption,subfig}
\usepackage{pgfplots}

\pgfplotsset{
   compat=newest,
   /pgf/number format/use comma,
}

\begin{document}
\begin{figure}[htbp]
\centering
\pgfplotsset{
  width=0.45\textwidth, height=.25\textheight,
  typeset ticklabels with strut% <- eingefügt
}
\subfloat[Caption 1 Caption 1 Caption 1 Caption 1 Caption 1]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=0,
    xmax=1.80,
    ymin=0,
    ymax=60000,
    xlabel={label x},
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 10000};
    \addlegendentry{\(x^3 + 3x + 10000\)}   
\end{axis}
\end{tikzpicture}
}%
\hfil
\subfloat[Caption 2 Caption 2 Caption 2 Caption 2 Caption 2]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=-25,
    xmax=25,
    ymin=0,
    ymax=100,
    xlabel={label x},
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 1};
    \addlegendentry{\(x^3 + 3x + 1\)}
\end{axis}
\end{tikzpicture}
}%
\caption{Caption 3}
\end{figure}

\end{document}

Re: Anordnung von zwei Diagrammen nebeneinander (mit Komma in xaxis)

von rais » Mi 17. Aug 2022, 20:43

Wenn Du genau hinschaust, siehst Du, daß die beiden `label x' bereits auf unterschiedlicher Höhe landen. Die Kommata besitzen eine Tiefe, die besagte Marke etwas weiter nach unten drängt, als die andere. Versuch es so:
\documentclass{article}
\usepackage{caption,subfig}
\usepackage{pgfplots}

\pgfplotsset{
   compat=newest,
   /pgf/number format/use comma,
   x tick label style={text depth=0.25ex}%<--
}

\begin{document}
\begin{figure}[htbp]
\centering
\pgfplotsset{width=0.45\textwidth, height=.25\textheight}
\subfloat[Caption 1 Caption 1 Caption 1 Caption 1 Caption 1]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=0,
    xmax=1.80,
    ymin=0,
    ymax=60000,
    xlabel={label x},
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 10000};
    \addlegendentry{\(x^3 + 3x + 10000\)}   
\end{axis}
\end{tikzpicture}
}%
\hfil
\subfloat[Caption 2 Caption 2 Caption 2 Caption 2 Caption 2]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=-25,
    xmax=25,
    ymin=0,
    ymax=100,
    xlabel={label x},
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 1};
    \addlegendentry{\(x^3 + 3x + 1\)}
\end{axis}
\end{tikzpicture}
}%
\caption{Caption 3}
\end{figure}

\end{document}
BTW: der Wert für `text depth' stammt hier aus der tikz-Doku, schau dort nach `dance around' (derzeit am Ende von Abschnitt 5.1) :wink:

VG
Rainer

Anordnung von zwei Diagrammen nebeneinander (mit Komma in xaxis)

von Kazter » Mi 17. Aug 2022, 08:51

Hallo zusammen,
leider komme ich nicht weiter.. Habe das Problem, dass die Ausrichtung der Bildunterschrift verrutscht, wenn ein Diagramm in der X-Achse eine Kommadarstellung hat und das andere nicht.

Kann mir jemand helfen. Vielen Dank!!
test.png
\documentclass{article}
\usepackage{caption,subfig}
\usepackage{pgfplots}

\pgfplotsset{
   compat=newest,
   /pgf/number format/use comma,
}

\begin{document}
\begin{figure}[htbp]
\centering
\pgfplotsset{width=0.45\textwidth, height=.25\textheight}
\subfloat[Caption 1 Caption 1 Caption 1 Caption 1 Caption 1]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=0,
    xmax=1.80,
    ymin=0,
    ymax=60000,
    xlabel={label x},
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 10000};
    \addlegendentry{\(x^3 + 3x + 10000\)}   
\end{axis}
\end{tikzpicture}
}%
\hfil
\subfloat[Caption 2 Caption 2 Caption 2 Caption 2 Caption 2]{%
\begin{tikzpicture}[baseline]
\begin{axis}[
    xmin=-25,
    xmax=25,
    ymin=0,
    ymax=100,
    xlabel={label x},
    ylabel={label y}
    ]
    \addplot {x^3 + 3*x + 1};
    \addlegendentry{\(x^3 + 3x + 1\)}
\end{axis}
\end{tikzpicture}
}%
\caption{Caption 3}
\end{figure}

\end{document}

Nach oben