2

Consider the following example:

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{subcaption}
\usepgfplotslibrary{patchplots}

\begin{document}
\begin{figure}
    \begin{subfigure}{0.33\textwidth}
        \centering
        \begin{tikzpicture}
           \pgfplotsset{%
                width=\linewidth,
                height=\linewidth
            }
            \begin{axis}[ticks=none,
            xmin=0,   xmax=1,
            ymin=0,   ymax=1,
            axis x line=bottom,
            axis y line=left,
            ]
            \addplot[
            patch,mesh,
            patch type=quadratic spline, 
            style=very thick,
            color=black]
            coordinates {
                (0,0) (0.9,0.9) (0.5,0.5^2)
            };
            \addplot[mark=none, color=gray] {x};
            \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \begin{subfigure}{0.33\textwidth}
        \begin{tikzpicture}
           \pgfplotsset{%
                width=\linewidth,
                height=\linewidth
            }
            \begin{axis}[ticks=none,
            xmin=0,   xmax=1,
            ymin=0,   ymax=1,
            axis x line=bottom,
            axis y line=left,
            ]
            \addplot[
            patch,mesh,
            patch type=quadratic spline, 
            style=very thick,
            color=black]
            coordinates {
                (0,0) (0.9,0.9) (0.5,0.5)
            };
            \addplot[mark=none, color=gray] {x};
            \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \begin{subfigure}{0.33\textwidth}
        \begin{tikzpicture}
           \pgfplotsset{%
                width=\linewidth,
                height=\linewidth
            }
            \begin{axis}[ticks=none,
            xmin=0,   xmax=1,
            ymin=0,   ymax=1,
            axis x line=bottom,
            axis y line=left,
            ]
            \addplot[
            patch,mesh,
            patch type=quadratic spline, 
            style=very thick,
            color=black]
            coordinates {
                (0,0) (0.9,0.9) (0.45,0.65)
            };
            \addplot[mark=none, color=gray] {x};
            \end{axis}
        \end{tikzpicture}
    \end{subfigure}
    \caption{Caption}
    \label{fig:my_label}
\end{figure} 
\end{document}

I would have expected my three plots to take up 1/3 of the page width each and be situated on a row next to each other. Instead I get this:enter image description here

Not only are they smaller than expected but even though they are smaller they for some reason do not seem to fit on one line but are placed on two lines. What is going on here‽

jonalv
  • 5,706
  • 9
  • 45
  • 64

0 Answers0