-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
fix colorbar corner cases (singleton) #3511
base: master
Are you sure you want to change the base?
Conversation
Ah that's good to fix all of those. What do you think, my feeling is that the super small limits are a bit confusing. My strategy so far, whenever I've thought about it specifically, was to either do the |
Yeah, the more I think about this, I'm neither satisfied with small values or the arbitrary
Good idea, here is the updated PR, IIUC: using CairoMakie
for v ∈ (0, 1)
x, y = [0, 1], [0, 2]
z = fill(float(v), length(x), length(y))
fig, ax, pl = heatmap(x, y, z)
Colorbar(fig[1, 2], pl)
save("$v-heatmap.png", fig)
display(fig)
fig, ax, pl = contourf(x, y, z)
Colorbar(fig[1, 2], pl)
save("$v-contourf.png", fig)
display(fig)
end
for v ∈ (0, 1)
x, y = randn(10), randn(10)
z = fill(float(v), length(x))
fig, ax, pl = tricontourf(x, y, z)
Colorbar(fig[1, 2], pl)
save("$v-tricontourf.png", fig)
display(fig)
end |
Hm I don't really like the contourf and tricontourf behavior. We have these colorbars with only one color (because they are categorical with one category but you don't easily understand that) but a range of values mapped to that color. So we don't know which uniform value we're plotting. While with heatmap, we can still recover the value, it's just that the range has to be arbitrarily chosen. So far, I've opted for behavior in Makie where you get an error when a singular value is supposed to be treated as a range. I find that more explicit (even though some error messages might be better) and it forces users to be clear what kind of bins they want. I do get that it's a bit inconvenient now and then. What do matplotlib and ggplot do here? |
This is what pyplot does: import pylab as plt
import numpy as np
x, y = [0, 1], [0, 2]
for v in (0, 1):
z = np.full((len(x), len(y)), float(v))
fig, ax = plt.subplots()
ct = ax.contourf(x, y, z)
fig.colorbar(ct)
fig.savefig(f'{v}-contourf.png')
fig, ax = plt.subplots()
ct = ax.pcolormesh(x, y, z)
fig.colorbar(ct)
fig.savefig(f'{v}-heatmap.png')
# fig, ax = plt.subplots()
# ct = ax.tricontourf(x, y, z)
# fig.colorbar(ct)
# fig.savefig(f'{v}-tricontourf.png') i.e. the singleton is extended from both side by an epsilon: Not sure what the right choice here is ... |
Description
Fix #3470.
Fix #3174.
colorrange
as suggested inColorbar
breaks with min limit == max limit #3174 (comment);Colorbar
with all zero heatmap #1739 (change arbitrary fallback limits, closer to PyPlot);contourf
andtricontourf
(as forheatmap
in FixColorbar
with all zero heatmap #1739), add tests.With this PR:
heatmap
contourf
tricontourf
Type of change
Delete options that do not apply:
Checklist