1

For some time now I have been trying to have two (or more) plots made with pgfplot side by side (figure below shows my goal for three), with the leftmost plot having the ylabel, the centre having the legend above it (or in case of an even number of plots having the legend centred between the two middle once). Finally, I would like for each plot to have a referencable label and caption (besides the xlabel)

However, the plot with the ylabel and the one with the legend always gets smaller (due to the added graphics of the label and the legend, I know) and I have not been able to find a solution to the issue. Is there a way to achieve what I want?

Below is the normal way I add three plots using subfigure:

\documentclass{report}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{subcaption}

\begin{filecontents}{data.csv} X,Y,Z,N 0,1,2,3 1,2,3,4 2,3,4,5 4,4,5,6 \end{filecontents}

\begin{document}

\begin{figure} \centering \begin{subfigure}[t]{.3\textwidth} \centering \begin{tikzpicture} \begin{axis}[ylabel=DATA TEXT, width=.95\textwidth] \addplot+ table[x=X, y=Y, col sep=comma] {data.csv}; \end{axis} \end{tikzpicture} \caption{\label{fig:y} Shows Y} \end{subfigure}~ \begin{subfigure}[t]{.3\textwidth} \centering \begin{tikzpicture} \begin{axis}[width=.95\textwidth, legend style={at={(0.5,1.5)},anchor=north,legend columns=2}] \addplot+ table[x=X, y=Z, col sep=comma] {data.csv}; \legend{DATA} \end{axis} \end{tikzpicture} \caption{\label{fig:z} Shows Z}
\end{subfigure}~ \begin{subfigure}[t]{.3\textwidth} \centering \begin{tikzpicture} \begin{axis}[width=.95\textwidth] \addplot+ table[x=X, y=N, col sep=comma] {data.csv}; \end{axis} \end{tikzpicture} \caption{\label{fig:n} Shows N}
\end{subfigure}
\end{figure} \end{document}

enter image description here

0 Answers0