Axis Ticks¶
tickmode: linear, array
tickformat: %, datetime
tickangle: default is
autoexponentformat
tickformatstops
place ticks and gridlines between categories
tick label angle¶
axis line and tick labels¶
axis date¶
xaxis=dict(
title=dict(text='date'),
#side='top', #show axis on top
mirror=True, #also show the axis line on the other side
ticks='outside',
showline=True,
linecolor='black',
gridcolor='lightgrey',
dtick='d1', #M1
tickformat='%d\n%b\n%Y', #%b\n%Y
)
axis range¶
axis ticks¶
fig.update_xaxes(
tickvals=x, # Specify the tick values
ticktext=xtick_labels, # Specify the tick labels
)
fig.update_layout(
xaxis=dict(
tickmode='array', # Enable the custom tick values and labels
tickvals=x, # Specify the tick values
ticktext=xtick_labels, # Specify the tick labels
)
)
example¶
https://plotly.com/python/tick-formatting/
import plotly.graph_objects as go
fig = go.Figure(go.Scatter(
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
y = [28.8, 28.5, 37, 56.8, 69.7, 79.7, 78.5, 77.8, 74.1, 62.6, 45.3, 39.9],
))
fig.update_layout(
xaxis = dict(
tickmode='linear',
tick0=0.5,
dtick=0.5,
)
)
fig.show()
Tickformat¶
fig.update_layout(
title='Time Series with Custom Date-Time Format',
xaxis_tickformat='%d %B (%a)<br>%Y',
yaxis_tickformat='%',
)
ticksuffix¶
Add a suffix to the tick labels