I am wondering if there is a standard way to include metadata like author’s name, date produced, or information about the dataset used to create an image directly in the output of the plotly json file.
I imagine that I could just add extra fields to the JSON object, but I wouldn’t want to accidentally corrupt it or make it unreadable from another system so I want to see if there is a built in way to do this.
1
help(go.Contour.meta
2
)
Help on property:
Assigns extra meta information associated with this trace that
can be used in various text attributes. Attributes such as
trace `name`, graph, axis and colorbar `title.text`, annotation
`text` `rangeselector`, `updatemenues` and `sliders` `label`
text all support `meta`. To access the trace `meta` values in
an attribute in the same trace, simply use `%{meta[i]}` where
`i` is the index or key of the `meta` item in question. To
access trace `meta` in layout attributes, use
`%{data[n[.meta[i]}` where `i` is the index or key of the
`meta` and `n` is the trace index.
The 'meta' property accepts values of any type
Returns
-------
Any|numpy.ndarray
LE: If you don’t intend to use data from meta in setting trace or layout attributes, but just for information, then the better way to define it is as an array of dicts:
import plotly.graph_objects as go
fig=go.Figure(go.Scatter(x=[1,2], y=[3, 1.5],
meta=[{"author": "Stephen P"}, {"team": "Xyz"}]))
fig.to_json(pretty=True)
But you can insert such an information in go.Layout.meta, as well.