Black Lives Matter. Please consider donating to Black Girls Code today.
Learn about the upcoming Dash Enterprise 4.0 release in the August 5th webinar with Chris Parmer, the Inventor of Dash.

Plotly express Line chart issue in getting months in order

Hello,
May I know how to get the months in order in express in line chart!
To access the line chart:
Plotly_data|690x153

Code is:
import plotly.graph_objs as go
fig = go.FigureWidget()

df_long=pd.melt(final_line_data, id_vars=[‘Month’], value_vars=[‘Amount_2016’, ‘Amount_2017’, ‘Amount_2018’, ‘Amount_2019’])
fig = px.line(df_long, x=‘Month’, y=‘value’, color=‘variable’)

fig.layout.xaxis.tickvals = pd.date_range(‘2016-01-01’, ‘2019-12-31’, freq=‘MS’)

fig.layout.xaxis.tickformat = ‘%y’

fig.show()

Earlier response is highly appreciated

final_line_data :

Month Amount_2016 Year_2016 Amount_2017 Year_2017 Amount_2018 Year_2018 Amount_2019 Year_2019
0 Apr 1395463.0 2016.0 NaN NaN NaN NaN NaN NaN
1 Aug 2016836.0 2016.0 NaN NaN NaN NaN NaN NaN
2 Dec 2300493.0 2016.0 NaN NaN NaN NaN NaN NaN
3 Jul 2098968.0 2016.0 NaN NaN NaN NaN NaN NaN
4 Jun 1748118.0 2016.0 NaN NaN NaN NaN NaN NaN

You can add the argument category_orders={"Month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]} to your px.line() call.

Hey Nicolas,
Great!

It’s working for me now. Thanks a lot.

Regards,
Bhagwat