-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Indicate color clipping and control clipping colors #686
Conversation
I don't get it -- what does it mean to extend the colorbar? It doesn't seem extended, it just now has a pointy end. Do you mean, make the colorbar visually indicate that it extends beyond the area shown, without actually changing the colorbar or the colormapping? If so that's not what the option name or the name of this issue suggests, and seems very confusing. |
True, the name isn't great, it's what matplotlib uses. |
This would also be more useful with an option to supply different colors for values that are above and below the range (and for NaN values). We can brainstorm about a nice way to specify that. |
|
I'm not sure it makes sense to provide direct control over this option, in HoloViews. Seems like HoloViews should just automatically turn it on if the user has selected a colormap that ends up clipping at a particular end of the colorbar, so that the visual representation is a reliable indicator of something meaningful. As it is, there's no relation between whether the user has explicitly enabled a pointy colorbar and anything about the actual plot, so indeed Jean-Luc's suggestion of calling it pointy_cbar is accurate! |
Using this to indicate clipping when clipping occurs does make a lot more sense. We would still need a parameter to turn this behaviour on and off though... |
Also I assume one problem this this suggestion is we might not know if clipping has occurred without inspecting the data range first? Sounds tricky...you might have to compare the data min/max with the limits to know if it should be pointy or not. |
It might be fairly straightforward and the overhead wouldn't be huge, so might be worth doing. Coupled with a way to specify special colors for min, max and NaN values that would be a nice addition. |
Sure. As long as there is a way to turn it off and keep the current behaviour in case it ever becomes a problem. I agree it would be a nice feature and I'm wondering if there might be a way to specify the NaN values and clipping colors at the same time... |
That makes sense: the user can optionally enable having pointy cbars indicate such clipping. That way, whenever there is such a pointy cbar, it does accurately reflect something about the current plot, rather than just being some meaningless style option. Yet those who don't ever want pointy cbars can turn them off. |
So since I actually needed this for some plots of mine I've gone ahead and implemented it. If you've got a better suggestion for the |
Apparently |
Sure, shouldn't be hard. |
@@ -497,8 +497,10 @@ class ColorbarPlot(ElementPlot): | |||
colorbar = param.Boolean(default=False, doc=""" | |||
Whether to draw a colorbar.""") | |||
|
|||
cbar_width = param.Number(default=0.05, doc=""" | |||
Width of the colorbar as a fraction of the main plot""") | |||
clipping_colors = param.Dict(default={'NaN': ('w', 1)}, doc=""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand what I expect to happen to NaN values but an example of how to set the min and max colors would be nice (in the docstring).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
Philipp tells me you would specify a max clipping like this: {'min': 'r', 'Nan': 'w'} Would setting these colors make the colorbar pointy as appropriate (if the data is clipped?). If so wouldn't an empty dictionary correspond to the current behaviour without pointy colorbars? |
No, not specifying a special color just sets the min and max color in the cmap as the clipping color, as in the example above. |
25945f8
to
1bc85cf
Compare
So why not have something like: cbar_extension = {'min': 'default', 'max':'default'} To indicate pointy colorbars with the min/max of the colormap where you can then specify your own custom colors instead of 'default'? |
Sounds good, if we can come up with a better name for the parameter. |
Maybe |
Given that |
Sure, if "clip" is accurate as a description about what it does (which I've somewhat lost track of by this point. :-) |
We already have Edit: Of course we could decide to rename those as well. |
In that case we should alias |
I'd suggest just calling it Edit: I guess why I was hesitant about the {'max': 'default'} suggestion is for the same reason, this parameter doesn't necessarily have anything to do with the colorbar, so enabling it that way feels a bit weird. |
|
See #689 for proposed UI. |
Ready to merge once clipping color support is fixed in bokeh: bokeh/bokeh#5323 |
@@ -748,6 +748,11 @@ class ColorbarPlot(ElementPlot): | |||
location, orientation, height, width, scale_alpha, title, title_props, | |||
margin, padding, background_fill_color and more.""") | |||
|
|||
clipping_colors = param.Dict(default={'NaN': (0, 0, 0, 1)}, doc=""" | |||
Dictionary to specify colors for clipped values, allows setting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RGBA tuples are fine though are any other color specifications allowed? E.g hex strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, docstring should be updated to reflect that.
e09e0b2
to
eebdaad
Compare
4db8ea6
to
9b3fc6a
Compare
94735b4
to
b306613
Compare
Looks good. Happy to merge when the tests pass. |
Tests have all passed. Merging. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
As the title says, adds a plot option to extend the colorbar in a particular. Here's an example:
Can also consider automatically enabling this if your data falls outside the specified range but that's another discussion.