MakieOrg / Makie.jl

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

hexbin: the colorbar does not scale automatically. #3631

Open gjankowiak opened 7 months ago

gjankowiak commented 7 months ago

Platform: linux, GPU not relevant IMHO.

When changing the number of points passed to an hexbin plot with an attached Colorbar, the latter is not updated as it should be. Here is a MWE which create such a plot, increases the number of points (shown as a scatter) and write the corresponding animation.

Should it scale automatically, like with heatmap for example?

import GLMakie as M

start_n = 10

x = M.Observable(randn(start_n))
y = M.Observable(randn(start_n))

fig = M.Figure(size=(720, 480))
ax = M.Axis(fig[1, 1], aspect=1)
ax.title = "$start_n points"
M.limits!(ax, (-2, 2), (-2, 2))

h = M.hexbin!(ax, x, y; bins=10)
cb = M.Colorbar(fig[1, 2], h)

M.scatter!(ax, x, y, markersize=1)

display(fig)

function step_n(new_n)
  x.val = randn(new_n)
  y[] = randn(new_n)
  ax.title = "$new_n points"
end

M.record(step_n, fig, "test_hexbin.mp4", 1000:1000:10001, framerate=1)

image

ffreyer commented 4 weeks ago

Seems like hexbin generates its own color array rather than using value-colors with colorrange, which Colorbar checks

asinghvi17 commented 4 weeks ago

I think there's a method that can be dispatched on to correct this for individual plot types, but forgot what it is...