Closed
Description
Some notes on integrating the new template (theme) support from plotly/plotly.js#2761 (original discussion from #924). With just rerunning code generation, in plotly.py 3.1+ template support is already usable. For example:
fig = go.FigureWidget()
fig.layout.template = {
'layout': {'paper_bgcolor': 'lightgray'},
'data': {'scatter': [{'mode': 'markers',
'marker': {'size': 20, 'symbol': 'square'}},
{'mode': 'markers',
'marker': {'size': 20, 'symbol': 'triangle'}},
]}}
fig.add_scatter(y=[3, 1, 3])
fig.add_scatter(y=[1, 3, 2])
fig
Here are some of my thoughts for improving the integration for plotly.py users:
- Write a custom validator for layout.template (right now it accepts anything and Plotly.js just ignores invalid properties)
- Include some way to set a global template that is the default unless if it overridden in the constructor. Support saving this default to a ~/.plotly settings file.
- Include a set of predefined named templates (like @sglyon did in WIP: adding themes #924).
- Figure out what's going on with the new
name
andtemplateitemname
properties that were added to all of the object array properties (e.g. annotations, images, etc.). I think thename
properties should only show up in the template hierarchy andtemplateitemname
should only show up in the normal object hiererahcy.
Metadata
Metadata
Assignees
Labels
No labels