Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hexbin fails when there are less than ~25 points #2898

Closed
sefffal opened this issue Apr 25, 2023 · 2 comments · Fixed by #2933
Closed

hexbin fails when there are less than ~25 points #2898

sefffal opened this issue Apr 25, 2023 · 2 comments · Fixed by #2933

Comments

@sefffal
Copy link

sefffal commented Apr 25, 2023

The hexbin plot command fails when the input size is small.

For example, the following command works as expected:

hexbin(randn(100), randn(100))

But this does not (see error message below):

hexbin(randn(10), randn(10))

It seems to me that hexbins should be well defined with arbitrarily few points.

X-ref: sefffal/PairPlots.jl#16

Tested with latest stable CairoMakie and Julia 1.9-rc2.

Error message:

Failed to show value:

Can't interpolate in a range where cmin == cmax. This can happen, for example, if a colorrange is set automatically but there's only one unique value present.

error(::String)@error.jl:35
interpolated_getindex@colorsampler.jl:36[inlined]
#70@colorsampler.jl:164[inlined]
iterate@generator.jl:47[inlined]
_collect(::Vector{Float32}, ::Base.Generator{Vector{Float32}, Makie.var"#70#71"{Vector{ColorTypes.RGBA{Float32}}, ColorTypes.RGBA{Float32}, ColorTypes.RGBA{Float32}, ColorTypes.RGBA{Float32}, Float32, Float32}}, ::Base.EltypeUnknown, ::Base.HasShape{1})@array.jl:802
collect_similar@array.jl:711[inlined]
map@abstractarray.jl:3261[inlined]
numbers_to_colors(::Vector{Float32}, ::Vector{ColorTypes.RGBA{Float32}}, ::GeometryBasics.Vec{2, Float32}, ::ColorTypes.RGBA{Float32}, ::ColorTypes.RGBA{Float32}, ::ColorTypes.RGBA{Float32})@colorsampler.jl:156
numbers_to_colors(::Vector{Float32}, ::MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}})@colorsampler.jl:147
to_cairo_color(::Vector{Float32}, ::MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}})@utils.jl:125
draw_atomic(::Makie.Scene, ::CairoMakie.Screen{CairoMakie.IMAGE}, ::MakieCore.Scatter)@primitives.jl:222
draw_plot(::Makie.Scene, ::CairoMakie.Screen{CairoMakie.IMAGE}, ::MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}})@infrastructure.jl:108
draw_plot(::Makie.Scene, ::CairoMakie.Screen{CairoMakie.IMAGE}, ::MakieCore.Combined{Makie.hexbin, Tuple{Vector{GeometryBasics.Point{2, Float32}}}})@infrastructure.jl:113
cairo_draw(::CairoMakie.Screen{CairoMakie.IMAGE}, ::Makie.Scene)@infrastructure.jl:49
backend_show(::CairoMakie.Screen{CairoMakie.IMAGE}, ::IOContext{IOBuffer}, ::MIME{Symbol("image/png")}, ::Makie.Scene)@display.jl:111
show(::IOContext{IOBuffer}, ::MIME{Symbol("image/png")}, ::Makie.FigureAxisPlot)@display.jl:193
@asinghvi17
Copy link
Member

I think this is because only one cell is being generated. We could put in some code to handle this.

@sefffal
Copy link
Author

sefffal commented May 4, 2023

Thinking more about this, I'm curious how only one cell could be generated for 10 random points.

Maybe there is also a bug in the bin-sizing algorithm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants