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 |