TransWikia.com

Vertically unaligned tikz plots

TeX - LaTeX Asked by ekosman on June 23, 2021

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

enter image description here

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

enter image description here

What could cause this issue?

One Answer

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
        }]
            addplot coordinates {(1,1000) (3,2000)};
        end{axis}
    end{tikzpicture}

    begin{tikzpicture}
        begin{axis}[y tick label style={text width=2cm%,align=right
        }]
            addplot coordinates {(1,100) (3,200)};
        end{axis}
    end{tikzpicture}
end{document}

It results in the following. enter image description here

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

Correct answer by Markus G. on June 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP