plotly.io
.write_jsonΒΆ
-
plotly.io.
write_json
(fig, file, validate=True, pretty=False, remove_uids=True, engine=None)ΒΆ Convert a figure to JSON and write it to a file or writeable object.
Note: A figure converted to JSON with one version of Plotly.py may not be compatible with another version.
- Parameters
fig β Figure object or dict representing a figure
file (str or writeable) β A string representing a local file path or a writeable object (e.g. a pathlib.Path object or an open file descriptor)
pretty (bool (default False)) β True if JSON representation should be pretty-printed, False if representation should be as compact as possible.
remove_uids (bool (default True)) β True if trace UIDs should be omitted from the JSON representation
engine (str (default None)) β
- The JSON encoding engine to use. One of:
βjsonβ for an engine based on the built-in Python json module
βorjsonβ for a faster engine that requires the orjson package
βautoβ for the βorjsonβ engine if available, otherwise βjsonβ
If not specified, the default engine is set to the current value of plotly.io.json.config.default_engine.
- Returns
- Return type