-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add to/from/read/write json functions to the plotly.io module #1188
Conversation
Note: failures seem to be due to npmjs being down: https://twitter.com/npmstatus/status/1042543988274692096 |
plotly/io/_json.py
Outdated
String containing the JSON representation of a figure | ||
output_type: type or str (default 'Figure') | ||
The output figure type or type name. | ||
One of: graph_objs.Figure, 'Figure, |
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.
missing quote character
plotly/io/_json.py
Outdated
One of: graph_objs.Figure, 'Figure, | ||
graph_objs.FigureWidget, 'FigureWidget' | ||
skip_invalid: bool (default False) | ||
False if invalid figure properties should result in an exception |
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.
and "True if invalid figure properties should be silently ignored."
plotly/io/_json.py
Outdated
output_type: type or str (default 'Figure') | ||
The output figure type or type name. | ||
One of: graph_objs.Figure, 'Figure, | ||
graph_objs.FigureWidget, 'FigureWidget' |
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.
Add newline
plotly/io/_json.py
Outdated
One of: graph_objs.Figure, 'Figure, | ||
graph_objs.FigureWidget, 'FigureWidget' | ||
skip_invalid: bool (default False) | ||
False if invalid figure properties should result in an exception |
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.
Update description as above
else: | ||
from mock import MagicMock | ||
from backports import tempfile | ||
|
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.
Add newline
# ---------------- | ||
if remove_uids: | ||
for trace in fig_dict.get('data', []): | ||
trace.pop('uid') |
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.
one of my traces was a Heatmap... which does not have a pop method
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.
Hmm, did you set validate=False
? If not, then validate_coerce_fig_to_dict()
should have made sure that the traces were converted into dict
s.
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 ended up using validate=False and remove_uids=False
This PR introduces 4 new functions to the
plotly.io
module for converting figures to and from JSON strings and files.These functions follow the
plotly.io
module conventions described in #1098Pending bug fixes in jupyterlab/jupyter-renderers#159, the JSON files written by
plotly.io.write_json
will be compatible with the@jupyterlab/plotly-extension
JupyterLab extension. This means it will be possible to create a figure in plotly.py, write it to afig.plotly.json
file, then double click the file in JupyterLab to view the figure right inside JupyterLab.