Change the size of a sub-figure?

Viewed 44

How can I make the scatter plot take up, say, 75% of the horizontal and vertical space?

using CairoMakie

    n = 3000
    r = randn(2,3000)
    x = @view r[1,:]
    y = @view r[2,:]
    
    fig = Figure(resolution = (1200, 800), font = "sans", fontsize = 20)
    ax1 = (Axis(fig[1, 1]))
    density!(ax1, y; bins = 20, color = :orange, strokewidth = 1,
        strokecolor = :black, label = "20 bins")
    
    ax3 = Axis(fig[2, 1]; xlabel = "value", ylabel = "counts")
    ax4 = Axis(fig[2, 2]; xlabel = "value", ylabel = "counts")
    scatter!(ax3, x, y; markersize = 4, color = :black,label="samples")
    axislegend(ax3; position = :rt)
    
    density!(ax4, x; label = "default",direction=:y)
    fig

Which currently looks like:

enter image description here

1 Answers

You can change them after the fact with

rowsize!(fig.layout, 2, Auto(3))
colsize!(fig.layout, 1, Auto(3))

See https://makie.juliaplots.org/stable/tutorials/layout-tutorial/ for more info on building layouts. enter image description here

Also, as Mikael writes in the comment below, you should probably link the axes with

linkxaxes!(ax1, ax3)
linkyaxes!(ax3, ax4)

when aligning the plots like this.

Related