# Vertically unaligned tikz plots

I'm working on a latex project and I use pgfplots for graphs. However, I encounter misalignment of them:

I notice that this problem completely disappears if I delete the axes data of the green and red curves:

What could cause this issue?

• I think that's impossible to say without knowing how your code is set up. Can you make a small, self-contained example demonstrating the problem (a minimal working example)? Jun 4, 2021 at 15:39
• I'm guessing here: The red and green graphs in the middle plot cause the labels to change from 3-digit to 4-digit and therefore, the proportions of the plot are different than the other two. I think there was an option to set the text-width of the ytick labels, but I couldn't find it just now. Jun 4, 2021 at 15:44
• I think @MarkusG. is right. The problem is fixed when I remove the y-labels. However, I need to present them. How can I overcome this issue? Jun 4, 2021 at 16:07
• have you checked groupplots of pgfplots? Maybe sharing your code as a MWE would help to test the issue. Jun 4, 2021 at 16:30
• I don't see how that would cause the misalignment you're talking about. I can't guess at the issue without seeing example code. Jun 4, 2021 at 16:32

I did find the option after all: y tick label style={text width=2cm} was the one I was looking for. Here is some example code (2cm is obviously way to large, but it proves the point) In an actual plot make sure to additionally use: align=right to make sure the numbers are aligned correctly at the axis.

\documentclass{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage{tikz,pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[y tick label style={text width=2cm%,align=right
}]
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[y tick label style={text width=2cm%,align=right
}]
\end{axis}
\end{tikzpicture}
\end{document}


It results in the following.

Note how both images are aligned correctly and have the same size.

• The problem here was vertical alignment, not horizontal alignment. Note the middle subfigure was a bit higher than the other two. If you move your two diagrams next to each other, and remove the ticklabel style, the alignment is still correct. So something else is up. Jun 4, 2021 at 16:28
• Yes, I see that, but since pgfplots has the tendency to change height and width to keep the aspect ratio, my guess was that proper vertical size should solve your vertical alignment issue as well. If you want better help that fits your example better, I suggest you provide a proper minimal working example for people to work with. Jun 4, 2021 at 16:30
• I'm not the OP. Jun 4, 2021 at 16:30
• Sorry, I didn't check that. But essentially we agree that without an MWE it is difficult to figure out, what the issue is, here. Jun 4, 2021 at 16:31
• That's exactly what I needed. Thank you for identifying the problems and giving me the fix! Jun 4, 2021 at 22:01