How to scale the axes in Makie subplots?

When I create subplots, the y-axis is usually taller than the x-axis. I want them to be of same (or at least similar) length. For example, the following code produces:

using CairoMakie

function plot()
    f= Figure()

    Axis(f[1, 1])
    barplot!(1:1:5, rand(5))

    barplot!(1:1:10, (rand(10)))

    return f

I would like the scale of both axes to be the same. How do I go about this? Thanks for the help.

That’s because the default figure size is 800x600, so halving that is going to produce something around 400x600 which is rather tall.

You can either let the figure size determine the plot sizes and do Figure(resolution = (800, 400)) or something to that effect.

Or you can predetermine the axis sizes, and then adjust the figure size to fit using resize_to_layout!() as described on the bottom of this page Aspect ratio and size control tutorial


Amazing! Thanks for the quick solution. :slight_smile: