【发布时间】:2021-05-20 06:07:00
【问题描述】:
我想更改饼图中切片的顺序。目前,切片按降序排列。我希望图表的切片按以下顺序排列: 是 > 有时 > 大多数时候 > 不
我正在使用以下代码:
colors = [ '#99f3bd', '#fbaccc','#a8df65', '#ff7b54']
fig, ax = plt.subplots(figsize=(5,15))
ax.set_title('Treatment Group', fontsize=25, fontname="Times New Roman Bold")
ax = df['q6_t'].value_counts(normalize=True).plot.pie(autopct='%1.0f%%', colors = colors)
ax.set_ylabel("")
plt.savefig('q6_t.png', bbox_inches = 'tight', transparent=True)
【问题讨论】:
标签: python pandas matplotlib data-analysis