TransWikia.com

Why do these two lines not look perpendicular in Tikz/PGFPlots?

TeX - LaTeX Asked by evencoil on January 6, 2021

This creates a simple plot with axes and the lines y = x and y = – x.

documentclass{standalone}

usepackage{tikz}
usepackage{pgfplots}
pgfplotsset{compat=1.13}

begin{document}

begin{tikzpicture}
begin{axis}[
    axis lines=middle,
    ticks=none,
]
    addplot[thick, black] {x};
    addplot[thick, black] {-1 * x};

end{axis}
end{tikzpicture}

end{document}

Produces this (the border is an artifact of my screenshot, but its not important):
enter image description here

If you hold up a 90 degree angle (say a piece of paper) to the intersection of the x and y axes you can see that they are nicely perpendicular.

However, if you do the same for the lines y = x and y = -x, you see that they are not perpendicular.

What gives?

One Answer

The axis is not square, so they shouldn't be perpendicular.

Either set the width and height to the same value in the axis options, or try adding axis equal, which will make the unit vectors in x and y have the same length.

Correct answer by Torbjørn T. on January 6, 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