Hey, I am dabbling into creating custom themes for my plots. I want to change the default behavior for axis ticks but figures seem to ignore their given template.
import plotly.graph_objects as go
fig = go.Figure(layout_template="plotly+x")
fig.add_trace(go.Scatter(
x=df['date'],
y=df['coverage'],
mode='lines+markers',
name='cov',
marker=dict(symbol='circle')
))
print(fig.layout.template.layout.xaxis)
>>> layout.XAxis({
'automargin': True,
'gridcolor': 'white',
'linecolor': 'white',
'minor': {'dtick': 86400000, 'ticks': 'outside'},
'nticks': 7,
'tickformatstops': [{'dtickrange': [None, 86400000], 'value': '\n%x %a'},
{'dtickrange': [86400000, None], 'value': '%x %A'}],
'ticks': '',
'title': {'standoff': 15},
'zerolinecolor': 'white',
'zerolinewidth': 2
})
print(fig.layout.xaxis)
>>> layout.XAxis()
fig.show()
The settings from my template are present in the figures layout.template, however this is not reflected in the shown plot. If I force the settings via fig.update_xaxes everything works as intended. Am I misunderstanding how templates are meant to work?
my template definition:
x = layout.Template(
{
"layout": {
"xaxis": {
'automargin': True,
"minor": {"dtick": 86400000, "ticks": "outside"},
"nticks": 7,
"tickformatstops": [
{"dtickrange": [None, 86400000], "value": "\n%x %a"},
{"dtickrange": [86400000, None], "value": "%x %A"},
],
},
"yaxis": {
"minor": {"dtick": 86400000, "ticks": "outside"},
"nticks": 7,
"tickformatstops": [
{"dtickrange": [None, 86400000], "value": "\n%x %a"},
{"dtickrange": [86400000, None], "value": "%x %A"},
],
},
},
}
)
using plotly 6.0.0