TeX - LaTeX Asked by Brad Hall on May 22, 2021
I simply want to create an equilateral triangle in LaTeX using pgfplots. I have computed the vertices of the triangle, and am using addplot coordinates to connect them.
documentclass{article}
usepackage{tikz}
usepackage{pgfplots}
pgfplotsset{compat=1.16}
begin{document}
begin{center}
begin{tikzpicture}[scale=2]
begin{axis}[
axis lines=none,
xmin=-1,xmax=1,
ymin=-1,ymax=1,
xtick=empty, ytick=empty,
xticklabels=empty, yticklabels=empty,
]
addplot coordinates {(0, -1) (-{sqrt(3)/2}, 0.5) ({sqrt(3)/2}, 0.5) (0, -1)};
end{axis}
end{tikzpicture}
end{center}
end{document}
The problem is, the resulting triangle is visually not an equilateral triangle, and instead is isosceles. Is this a scaling issue, or an issue with pgfplots itself? Hopefully my math isn’t wrong!
You need the option axis equal
added to key-value list of axis
environment.
In axis
environment, by default the plot is scaled to a 240pt x 207pt rectangle (see documentation of axisdefaultwidth
and axisdefaultheight
in pgfplots
' manual), so that the unit length for x and y axis are usually different.
Correct answer by muzimuzhi Z on May 22, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP