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

Use discrete colorbars for contours and polygons #1856

Closed
rabernat opened this issue Sep 7, 2017 · 7 comments
Closed

Use discrete colorbars for contours and polygons #1856

rabernat opened this issue Sep 7, 2017 · 7 comments

Comments

@rabernat
Copy link

rabernat commented Sep 7, 2017

If I take the simple contour example from the docs and add a filled=True option, the %%opts seem to have no effect. I can no longer change the cmap or add a colorbar:

%%opts Contours [show_legend=False colorbar=True width=325] (cmap='fire')
x,y = np.mgrid[-50:51, -50:51] * 0.05
img = hv.Image(np.sin(x**2+y**3))
z0, z1 = img.range('z')
hv.operation.contours(img, levels=np.linspace(z0, z1, 5), overlaid=False, filled=True)

image

Holoviews version is 1.8.3-x-ga66181c36 via conda-forge.

Possibly related to #1558

@philippjfr philippjfr added type: bug Something isn't correct or isn't working tag: component: plotting labels Sep 7, 2017
@philippjfr
Copy link
Member

philippjfr commented Sep 15, 2017

This is probably somewhat confusing but at least with latest master this works correctly if you set the options on Polygons, Contours is just used for the non-filled case:

%%opts Polygons [show_legend=False colorbar=True width=325] (cmap='fire' line_width=0.1)
x,y = np.mgrid[-50:51, -50:51] * 0.05
img = hv.Image(np.sin(x**2+y**3))
z0, z1 = img.range('z')
hv.operation.contours(img, levels=np.linspace(z0, z1, 10), overlaid=False, filled=True)

bokeh_plot

@jlstevens
Copy link
Contributor

That looks pretty! Might be one to add to the gallery...

@rabernat
Copy link
Author

Great work!

My only comment would be that, with contour plots with discrete levels, we like to see discrete colorbars. This helps to read the precise values from the plot.

In matplotlib it looks like this:
contours

@philippjfr
Copy link
Member

Good point, we need to improve our handling for discrete colormaps in general.

@jlstevens
Copy link
Contributor

Perhaps we should repurpose this issue to be about discrete colormaps?

@philippjfr philippjfr added type: feature A major new feature and removed type: bug Something isn't correct or isn't working labels Oct 22, 2017
@philippjfr philippjfr changed the title can't produce a colorbar with filled contours Use discrete colorbars for contours and polygons Oct 22, 2017
@philippjfr
Copy link
Member

We now support a color_levels argument for discrete color mapping.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants