MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.41k stars 312 forks source link

resize_to_layout! for GridLayout doesn't resize the content #2652

Open lazarusA opened 1 year ago

lazarusA commented 1 year ago

Doing the following:

using GLMakie

d = rand(1400,700)
s = size(d)
aspect = s[1]/s[2]

fig = Figure()
ax = Axis(fig[1,1])
obj = heatmap!(ax, 1..s[1], 1..s[2], d)
Colorbar(fig[1,2], obj)
colsize!(fig.layout, 1, Aspect(1, aspect))
colgap!(fig.layout, 10)
resize_to_layout!(fig)
fig

gives a nice heatmap with a good colorbar.

Now, if we do it with a GridLayout

fig = Figure()
g = GridLayout(fig[1,1])
ax = Axis(g[1,1])
obj = heatmap!(ax, 1..s[1], 1..s[2], d)
Colorbar(g[1,2], obj)
colsize!(g, 1, Aspect(1, aspect))
colgap!(g, 10)
resize_to_layout!(fig)
fig

things are not ok. Bug?

The motivation here is to use n GridLayout's to plot several independent heatmaps with their corresponding colorbars, taking into account the data aspect ratio. Any ideas?

asinghvi17 commented 1 year ago

Looks like this uses GridLayoutBase.tight_bbox internally. Perhaps the solution is to simply change the widths of each grid layout recursively as well?