我目前正在使用plotlyexpress 来创建Sunburst 图表。然而,我意识到孩子们的标称值是按字母顺序排列的。特别是对于绘制非常不幸的月份......你知道如何处理这个问题吗?也许是财产或某种解决方法?下面有一个例子,你可以自己尝试一下。提前致谢!
import plotly.express as px
import pandas as pd
import calendar
months = [x for x in calendar.month_name if x]
#Create Dataframe
data = []
for m in months:
data.append(['2018', m, 2])
df = pd.DataFrame(data, columns=['Year', 'Month', 'Value'])
#Compute Sunburst
fig = px.sunburst(df, path=['Year', 'Month'], values='Value')
fig.show()
Run Code Online (Sandbox Code Playgroud)