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

Update plotly backend to support plotly.py version 3 #3194

Merged
merged 15 commits into from Nov 25, 2018

Conversation

Projects
None yet
2 participants
@jonmmease
Copy link
Collaborator

jonmmease commented Nov 24, 2018

This PR updates the plotly backend to be compatible with (and require) plotly.py version 3.4+. This closes #2864.

I left a detailed commit trail explaining the updates, but let me know if you have any questions! For more background, see the plotly.py version 3 migration guide.

jonmmease added some commits Nov 24, 2018

'k' is not a valid plotly color string, use 'black' instead
's' is not a valid plotly symbol string, use 'circle' instead
'plasma' is not a valid plotly colorscale, use 'viridis' instead
Rename global plotly library object in JavaScript
The global plotly library object was renamed from 'Plotly' to '_Plotly'
in plotly.py 3.4.0 to avoid a naming conflict when a Jupyter Notebook
heading contained the text 'Plotly'

See:
plotly/plotly.py#816
plotly/plotly.py#1250
Replace use of deprecated graph object classes
Graph objects are now structured hierarchically, so go.Marker was
deprecated in favor of go.layout.Marker.  The use of these classes
is fully optional, and they can be replaced by plain dict instances in
cases where local validation, tab completions, and docstrings aren't
needed.
The figure.data property is now a tuple rather than a list, so it
cannot be mutated in place. Instead, the add_traces method is used
to append additional traces to the figure.
Object arrays (like annotations) are now stored as tuples
rather than lists so they cannot be extended in place.
The += operator can be used instead to replace the object array with
an extended version of itself.
Graph objects are no longer dict subclasses, they are wrappers around
dict instances with some dict-like methods. The to_plotly_json method
is used to convert a graph object into a Python dict.
When exporting to standalone html the plotly library is loaded as Plotly
but when loaded into the notebook it is loaded as _Plotly.

(before this commit figures rendered properly in the jupyter notebook
but an error was raised when output to an HTML file that _Plotly is
not defined)
Run conda env update with travis_wait command to (hopefully) avoid CI…
… timeout.

See https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received

Prior intermittent CI error:
```
...
$ conda env update -n holoviews -q -f environment.yml
Solving environment: ...working... done
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... dbus post-link :: /etc/machine-id not found ..
dbus post-link :: .. using /proc/sys/kernel/random/boot_id
No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
```
@philippjfr

This comment has been minimized.

Copy link
Contributor

philippjfr commented Nov 25, 2018

This is brilliant @jonmmease, I really, really appreciate it. I was going to work on this pretty much starting tomorrow in anticipation of releasing next week.

figure['data'].extend(fig['data'])

figure.add_traces(fig.data)
print(type(self), self.projection)

This comment has been minimized.

@philippjfr

philippjfr Nov 25, 2018

Contributor

Would be good to remove this.

This comment has been minimized.

@jonmmease

jonmmease Nov 25, 2018

Author Collaborator

Whoops, missed that one. removed in ed65c14

@philippjfr

This comment has been minimized.

Copy link
Contributor

philippjfr commented Nov 25, 2018

Left one minor comment but once that's resolved I'd be happy to merge this.

@philippjfr

This comment has been minimized.

Copy link
Contributor

philippjfr commented Nov 25, 2018

One quick unrelated question, I just merged a PR which let's users map columns in their data directly onto the style attributes of the artist/glyph, but haven't ported this feature to plotly yet. How flexible is plotly with setting vectorized properties, e.g. to control the alpha/linewidth/color per point/simplex/line segment etc.?

@jonmmease

This comment has been minimized.

Copy link
Collaborator Author

jonmmease commented Nov 25, 2018

Most of the properties of scatter.marker and bar.marker can be specified as vectors. Off the top of my head, scatter (2D, 2D WebGL, and 3D) supports vectorized color, opacity, size, and symbol and bar supports vectorized height (of course 🙂), baseline, bar width, line width, opacity, bar color, and outline color,

plotly.js doesn't really support vectorizing line properties at this point, i.e. you can't currently vary the color or width of a line within the line.

Also, I'd like to write out a summary of the areas where I think the plotly renderer could be enhanced by taking advantage of existing plotly.py/plotly.js features. If this is agreeable on your end, would you prefer one large master issue or a bunch of smaller issues (maybe with a plotly label)?

@philippjfr

This comment has been minimized.

Copy link
Contributor

philippjfr commented Nov 25, 2018

Most of the properties of scatter.marker and bar.marker can be specified as vectors.

Thanks, that's really helpful.

plotly.js doesn't really support vectorizing line properties at this point, i.e. you can't currently vary the color or width of a line within the line.

Not really surprising, neither does bokeh or matplotlib.

Also, I'd like to write out a summary of the areas where I think the plotly renderer could be enhanced by taking advantage of existing plotly.py/plotly.js features.

That list of probably very long, the plotly renderer exists mostly as a proof of concept and as quick release valve for us to support interactive 3D plots. Let's start by putting that in one issue and then we can break that up into smaller sub-issues.

Once again I'm really impressed by your work on plotly, and really appreciate you taking the time to update this code. I'll merge now to get the basics working again.

@philippjfr philippjfr merged commit 80a037a into pyviz:master Nov 25, 2018

3 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.3%) to 89.4%
Details
s3-reference-data-cache Test data is cached.
Details

@jonmmease jonmmease deleted the jonmmease:plotly3 branch Nov 25, 2018

@jonmmease jonmmease referenced this pull request Nov 26, 2018

Open

Master list of potential Plotly backend enhancements #3196

6 of 21 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.