X and y axis equal scaling

How do I make the x and y axis have equal scaling?
If can cheat it with size = (800,800), for example, but then if I add labels or a title, or change the axis limits, this requires a lot of adjusting. Is there any way I can make it automatic?

using Plots

x(u) = u
y(u) = sqrt(u)
y2(u) = -sqrt(u)
plot(x, [y, y2], 0, 5,
    framestyle = :origin,
    legend = :none,
    linecolor = :blue,
    xlim = [-6, 6],
    ylim = [-6, 6],
    ticks = -6:1:6,
    xlabel = "y"
)
1 Like

Use the keyword argument aspect_ratio = 1.

3 Likes

Can also use aspect_ratio=:equal to indicate that 1 unit on the x-axis should equal 1 unit on the y-axis, regardless of the axis bounds.