Ich möchte die folgenden drei Plots sauber ausrichten, so dass das obere linke Plot mit dem unteren linken Plot linksbündig ausgerichtet ist. Wie geht das am besten?

\documentclass[12pt,a5paper]{article}
    \usepackage[utf8]{inputenc}
    \usepackage{fontenc}
    \usepackage[ngerman]{babel}
    \usepackage{tikz,pgfplots}
    \usepackage{graphicx,caption,floatrow,subcaption}
    \usepackage{siunitx}
    \usepgfplotslibrary{groupplots}
    \usetikzlibrary{arrows.meta}
    \pgfplotsset{compat=1.18}

    \begin{document}

    \begin{figure}
    \begin{subfigure}[t]{0.49\linewidth}
    \centering
    \begin{tikzpicture}
    \begin{scriptsize}
        \begin{axis}[width=1\linewidth]
      \addplot {x^2 - x +4}; 
            \end{axis}
    \end{scriptsize}
    \end{tikzpicture}
    \caption{xxx}

    \end{subfigure}
    %\hfill
    \begin{subfigure}[t]{0.49\linewidth}
    \centering
    \begin{tikzpicture}
    \begin{scriptsize}
        \begin{axis}[width=1\linewidth]
      \addplot {x^2 - x +4};

                        \end{axis}
    \end{scriptsize}
    \end{tikzpicture}
    \caption{yyy}

    \end{subfigure}\\

    \vspace{1em}

    \begin{subfigure}[t]{0.49\linewidth}
    \begin{tikzpicture}
    \begin{scriptsize}
        \begin{axis}[width=1\linewidth,     legend pos= outer north east,]
      \addplot {x^2 - x +4}; 
                            \addlegendentry{test}
            \end{axis}
    \end{scriptsize}
    \end{tikzpicture}
    \caption{zzz}
    \label{sfig:indHVst5Ac} 
    \end{subfigure}
    %\hfill
    \begin{minipage}[t]{0.1\linewidth}
    \end{minipage} 
    \caption{test}
    \end{figure}

    \end{document}

gefragt 10 Mär '23, 21:34

wiewowas's gravatar image

wiewowas
437193039
Akzeptiert-Rate: 40%


Du kannst die Boundingbox der einzelnen Plots anpassen und dann die Ausrichtung entsprechend vornehmen:

\documentclass[12pt,a5paper]{article}
\usepackage{fontenc}
\usepackage[ngerman]{babel}
\usepackage{pgfplots}% lädt tikz, graphicx, xcolor, ...
\usepackage{subcaption}% lädt caption

\pgfplotsset{compat=1.18}

\begin{document}
\begin{figure}
  \scriptsize% das ist ein Schalter und keine Umgebung!
  \begin{subfigure}[t]{0.49\linewidth}
    \centering
    \begin{tikzpicture}
      \begin{axis}[width=1\linewidth]
        \addplot {x^2 - x +4}; 
      \end{axis}
      \pgfresetboundingbox
      \path (current axis.below south west) rectangle (current axis.above north east);
    \end{tikzpicture}
    \caption{xxx}
  \end{subfigure}% <- Leerzeichen auskommentiert
  \hfill
  \begin{subfigure}[t]{0.49\linewidth}
    \centering
    \begin{tikzpicture}
      \begin{axis}[width=1\linewidth]
        \addplot {x^2 - x +4};
      \end{axis}
      \pgfresetboundingbox
      \path (current axis.below south west) rectangle (current axis.above north east);
    \end{tikzpicture}
    \caption{yyy}
  \end{subfigure}

  \vspace{1em}

  \begin{subfigure}[t]{0.49\linewidth}
    \centering
    \begin{tikzpicture}
      \begin{axis}[width=1\linewidth,legend pos= outer north east]
        \addplot {x^2 - x +4}; 
        \addlegendentry{test}
      \end{axis}
      \pgfresetboundingbox
      \path (current axis.below south west) rectangle (current axis.above north east);
    \end{tikzpicture}
    \caption{zzz}
    \label{sfig:indHVst5Ac} 
  \end{subfigure}
  \caption{test}
\end{figure}
\end{document}

Wenn die Beschriftungen an der y-Achse jeweils die gleiche Breite haben, geht auch kürzer

\documentclass[12pt,a5paper]{article}
\usepackage{fontenc,showframe}
\usepackage[ngerman]{babel}
\usepackage{pgfplots}% lädt tikz, graphicx, xcolor, ...
\usepackage{subcaption}% lädt caption

\pgfplotsset{compat=1.18}

\begin{document}

\begin{figure}
  \scriptsize% <- das ist ein Schalter und keine Umgebung
  \begin{subfigure}[t]{0.49\linewidth}
    \centering
    \begin{tikzpicture}
      \begin{axis}[width=1\linewidth]
        \addplot {x^2 - x +4}; 
      \end{axis}
    \end{tikzpicture}
    \caption{xxx}
  \end{subfigure}%
  \hfill
  \begin{subfigure}[t]{0.49\linewidth}
    \centering
    \begin{tikzpicture}
      \begin{axis}[width=1\linewidth]
        \addplot {x^2 - x +4};
      \end{axis}
    \end{tikzpicture}
  \caption{yyy}
  \end{subfigure}

  \vspace{1em}

  \begin{subfigure}[t]{0.49\linewidth}
    \centering
    \begin{tikzpicture}
      \begin{axis}[width=1\linewidth, legend pos= outer north east]
        \addplot {x^2 - x +4}; 
        \addlegendentry{test}
      \end{axis}
      \pgfresetboundingbox
      \path (current axis.outer south west) rectangle (current axis.above north east);
    \end{tikzpicture}
    \caption{zzz}
    \label{sfig:indHVst5Ac} 
  \end{subfigure}
  \caption{test}
\end{figure}
\end{document}
Permanenter link

beantwortet 15 Mär '23, 11:41

esdd's gravatar image

esdd
17.7k254256
Akzeptiert-Rate: 62%

Deine Antwort
Vorschau umschalten

Folgen dieser Frage

Per E-Mail:

Wenn sie sich anmelden, kommen Sie für alle Updates hier in Frage

Per RSS:

Antworten

Antworten und Kommentare

Markdown-Grundlagen

  • *kursiv* oder _kursiv_
  • **Fett** oder __Fett__
  • Link:[Text](http://url.com/ "Titel")
  • Bild?![alt Text](/path/img.jpg "Titel")
  • nummerierte Liste: 1. Foo 2. Bar
  • zum Hinzufügen ein Zeilenumbruchs fügen Sie einfach zwei Leerzeichen an die Stelle an der die neue Linie sein soll.
  • grundlegende HTML-Tags werden ebenfalls unterstützt

Frage-Themen:

×6
×5

gestellte Frage: 10 Mär '23, 21:34

Frage wurde gesehen: 1,295 Mal

zuletzt geändert: 15 Mär '23, 11:41