2

I have 4 plots generated by pgfplots that I would like vertically and horizontally aligned. They are all included in my main file via \input. Due to memory constraints two of them live in one file while the other two are in separate files. I use the externalize feature to prevent re-compilation of the plots every time I compile my document. Here's the part of my main file that pertains to the plots:

\begin{figure}
\centering
\input{Inhalt/Abbildungen/LaTeX/TailDependence_Funktionen}
  \input{Inhalt/Abbildungen/LaTeX/Scatterplot_norm}
  \input{Inhalt/Abbildungen/LaTeX/Scatterplot_t}

\caption{Funktionen und Scatterplot}
\end{figure}

I've tried various combinations of trim axis leftand trim axis right. All plots are scaled to 0.81. I can get close by using trim axis lefton the plots on the left side and trim axis righton the plots on the right side. So my tikzpicture environments look like this:

\begin{tikzpicture}[scale=0.81, trim axis left]

or

\begin{tikzpicture}[scale=0.81, trim axis right]

This is what it looks like right now:

Current situation

I would like the y-axes of the two plots on the left aligned as well as the y-axes of the two plots on the right. At the moment the alignment is a little off.

As my plots rely on external data files I'm not sure how to provide a MWE but will try my best if necessary.

Andrew Swann
  • 95,762
user2249626
  • 1,653
  • If you cannot do anything else, you can play around with the y label style with introducing shifts. – percusse Mar 22 '15 at 09:46
  • 3
    Did you look at the groupplot functions in pgfplots? You might find it easier to group all four plots in pgf and then externalize the result (to avoid recompilation) - or make a PDF with an external tool, like "lattice" graphics in R, which excels at multiple plots like this. – Thruston Mar 22 '15 at 10:30
  • I might try that. However, I'm not sure whether it would cause the memory limit to be exceeded. – user2249626 Mar 22 '15 at 10:39
  • The mis-alignnments are probably due to text, both the y axis label and x axis numbers which go over the edge. You could create a uniform size for all the plots by placing a \coordinate outside the axis at a uniform distance in opposite corners. – John Kormylo Mar 22 '15 at 19:10
  • try using the style ylabel absolute . This will position the y labels at exactly the same distance to the axis (without respecting any tick labels). It is essentially the same idea as suggested by @percusse except that this uses a predefined distance. – Christian Feuersänger Oct 07 '17 at 11:41

1 Answers1

1

You can fine tune the offsets to be big enough without excess white space using \draw.

aligned

\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc}

\begin{document}
\begin{minipage}{4 in}
\centering
\begin{tikzpicture}
  \begin{axis}[ylabel={Y label},xmin=-1,xmax=1,width=3in,height=2in]
    \addplot coordinates {(-1,-1) (1,1)};
    \coordinate (NE) at (rel axis cs: 1,1);% upper right corner of axis
  \end{axis}
  \path (-15mm,-5mm) ($(NE)+(3mm,2mm)$);
  %\draw[red] (-15mm,-5mm) rectangle ($(NE)+(3mm,2mm)$);% to fine tune offsets
\end{tikzpicture}

\begin{tikzpicture}
  \begin{axis}[xmin=-10,xmax=10,width=3in,height=2in]
    \addplot coordinates {(-10,-10) (10,10)};
    \coordinate (NE) at (rel axis cs: 1,1);
  \end{axis}
  \path (-15mm,-5mm) ($(NE)+(3mm,2mm)$);
  %\draw[red] (-15mm,-5mm) rectangle ($(NE)+(3mm,2mm)$);% to fine tune offsets
\end{tikzpicture}
\end{minipage}
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120