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

Colorscale/colorbar fixes for Plotly backend #3590

Merged
merged 5 commits into from
Mar 31, 2019
Merged

Colorscale/colorbar fixes for Plotly backend #3590

merged 5 commits into from
Mar 31, 2019

Conversation

jonmmease
Copy link
Collaborator

This PR includes various fixes related to colorscale/colorbar handling for the plotly backend

Commit summary:

  • 8eb78b0: This addresses cmap for Surfaces not working with plotly #3414 by limiting the length of colorscales passed to plotly.js to a maximum of 255. Longer colorscales are subsampled. Plotly.js performs its own colorscale interpolation so I don't foresee this causing visual artifacts for any reasonably smooth colorscale.
import numpy as np
import holoviews as hv
from holoviews import dim
from holoviews import opts
hv.extension('plotly')

surface = hv.Surface(np.sin(np.linspace(0,100*np.pi*2,10000)).reshape(100,100))
surface.opts(cmap='fire', height=500, width=500, colorbar=True)

newplot-1

  • 1ffdef1: Fix for the case where a named colorscale is known only to plotly.py. Previously this resulted in a malformed colorscale.
surface = hv.Surface(np.sin(np.linspace(0,100*np.pi*2,10000)).reshape(100,100))
surface.opts(cmap='Picnic', height=500, width=500, colorbar=True)

newplot-2

  • 9cc745b: Fixes colorbar and edges_color handling. Both of these options are applied to separate traces (separate from the main mesh3d trace) which were being dropped. With these changes, an Element may be represented by a series of traces instead of only 1.
y,x = np.mgrid[-5:5, -5:5] * 0.1
heights = np.sin(x**2+y**2)
trisurface = hv.TriSurface((x.flat,y.flat,heights.flat))

trisurface.opts(height=500, width=500, cmap='plasma', colorbar=True, edges_color='cyan')

newplot-3

  • 016a137: Add/fix colorbar/colorscale handling for the plotly bivariate element. Previously, the cmap and colorbar args were ignored.
normal = np.random.randn(1000, 2)
biv = hv.Bivariate(normal)
biv.opts(filled=True, cmap='cividis', showlines=True, colorbar=True)

newplot-4

normal = np.random.randn(1000, 2)
biv = hv.Bivariate(normal)
biv.opts(filled=False, cmap='plasma', showlines=True, colorbar=True)

newplot-5

  • I tried out the colorbar/colorscale handling of other Elements and the rest of them worked fine.
  • 8fb44d8: Adds a few additional colorbar test cases

@philippjfr
Copy link
Member

This is great, thanks a lot! Subsampling the color scales sounds good to me as well, no reason to send the full palettes unlike in bokeh where interpolation is not implemented client-side.

@philippjfr
Copy link
Member

Not sure what's up with the tests yet, seems unrelated.

@jonmmease
Copy link
Collaborator Author

Thanks! I'm taking a look at the tests as well.

@philippjfr
Copy link
Member

Ah, I know what happened, the new param release dev release changed the formatting of warnings. I'll fix that in a separate PR shortly.

@jonmmease
Copy link
Collaborator Author

Ah, I know what happened, the new param release dev release changed the formatting of warnings. I'll fix that in a separate PR shortly.

Thanks for the detective work 🙂

@philippjfr
Copy link
Member

Hopefully fixed in #3591

plotly/plotly.js#3699. Plotly.js performs
colorscale interpolation internally so reducing the number of colors
here makes very little difference to the displayed colorscale.
previously an invalid colorscale was being constructed because the
colorscale list of pairs was treated as if it were a list of colors
@philippjfr
Copy link
Member

Thanks again @jonmmease.

@philippjfr philippjfr merged commit f8033a2 into master Mar 31, 2019
@jonmmease jonmmease deleted the bug_3414 branch March 31, 2019 16:35
Copy link

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.

@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

Successfully merging this pull request may close these issues.

2 participants