Holoviews: Use discrete colorbars for contours and polygons

Created on 7 Sep 2017  路  6Comments  路  Source: holoviz/holoviews

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

tag plotting feature

Most helpful comment

We now support a color_levels argument for discrete color mapping.

All 6 comments

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

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

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

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

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

We now support a color_levels argument for discrete color mapping.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cristi-neagu picture cristi-neagu  路  5Comments

ahundt picture ahundt  路  6Comments

obust picture obust  路  5Comments

Forander picture Forander  路  6Comments

bstadlbauer picture bstadlbauer  路  3Comments