🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

Change date format with categorical labels in scatter plot

Hi all,

I am creating a time series chart with categoryorder. However, I would like to changed my date format to “%b %Y”, but what I got was “%Y%m%d”

This is part of my script:

lastBdates = pd.date_range(yr1, periods=12, freq=‘BM’).strftime("%Y%m%d").tolist()
list[‘date’] = pd.to_datetime(list[‘date’])
widget = html.Div([
dcc.Graph(
figure=go.Figure(
data=[go.Scatter(
x=list[‘date’],
y=list[‘risk’],
mode=‘lines+text’,
text=riskContribution,
textposition=‘auto’,
cliponaxis=False,
textfont=dict(
size=13,
color=’#323b47’),
marker={‘size’: 15, ‘line’: {‘width’: 0.5, ‘color’: ‘white’}})],
layout=go.Layout(xaxis=dict(categoryorder=‘array’, categoryarray=list[‘date’], type=“category”),
# layout=go.Layout(
# xaxis=dict(tickformat=’%b %Y’),
margin={‘l’: 40, ‘b’: 20, ‘t’: 10, ‘r’: 20}, height=100)),
style={‘vertical-align’: ‘middle’},
id=‘time-series-graph-figure’
)
])

Thank you,
Erica