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

Colorbar breaks with min limit == max limit #3174

Open
eliascarv opened this issue Aug 22, 2023 · 7 comments · May be fixed by #3511
Open

Colorbar breaks with min limit == max limit #3174

eliascarv opened this issue Aug 22, 2023 · 7 comments · May be fixed by #3511
Labels
bug Errors & Warnings Missing/Bad errors Legend & Colorbar Makie Backend independent issues (Makie core)

Comments

@eliascarv
Copy link

Code to reproduce the error:

julia> using GLMakie

julia> fig = Figure()

julia> Axis(fig[1, 1])
Axis with 0 plots:


julia> Colorbar(fig[1, 2], limits = (1, 1))
ERROR: ArgumentError: range step cannot be zero
@eliascarv eliascarv added the bug label Aug 22, 2023
@lazarusA
Copy link
Contributor

what would be the expected output? a colorbar with one color (a categorical cmap)?

@eliascarv
Copy link
Author

Yes, I was expecting a colormap with just one color and one value.

@jkrumbiegel
Copy link
Member

colors are interpolated by scaling the colorrange to 0, 1 and mapping that to the colorscheme's colors. If you have a colorrange of width 0, you can't look up any value in the colorscheme

@jkrumbiegel
Copy link
Member

The error message is not good though

@eliascarv
Copy link
Author

Maybe, for this corner case, generate a Colorbar with the first color of the color scheme or without color just with the border and the value. Another option would be to display a warning and show an empty Colorbar or display a warning and not show the Colorbar.

@jkrumbiegel
Copy link
Member

jkrumbiegel commented Aug 23, 2023

I'm pretty against warnings, they make it hard to let code run automatically, on CI, etc. Often people don't see these warnings and then wonder later why some colorbar is empty. Also I don't really like doing the "next best thing" if behavior is essentially undefined. I'd go for a clearer error here. Errors stop people in their tracks and make them question what they're doing :)

@eliascarv
Copy link
Author

eliascarv commented Aug 23, 2023

I agree. A clearer error message seems like the best way to go.

@t-bltg t-bltg linked a pull request Dec 25, 2023 that will close this issue
7 tasks
@ffreyer ffreyer added Errors & Warnings Missing/Bad errors Legend & Colorbar Makie Backend independent issues (Makie core) labels Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Errors & Warnings Missing/Bad errors Legend & Colorbar Makie Backend independent issues (Makie core)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants