【发布时间】:2021-09-08 12:16:42
【问题描述】:
如何使用 matplotlib 将饼图中的百分比标签颜色更改为白色而不干扰文本标签颜色?当我编辑 textprops={'size': 'x-large','color':'w'} 时,文本颜色会变成白色,与背景没有对比。
labels = df01['new_sentiment']
count = df01['count']
cmap = plt.get_cmap('Greys')
colors = list(cmap(np.linspace(0.45, 0.85, len(count))))
fig1, ax1 = plt.subplots()
ax1.pie(count, labels=labels, autopct='%1.1f%%', textprops={'size': 'x-large'}, colors=colors)
ax1.axis('equal')
plt.title('7D-prior-PM_sem_sen', pad=30)
plt.savefig('04_7D-prior-PM_sem_sen.tiff', dpi=300, format='tiff', bbox_inches='tight')
【问题讨论】:
标签: python matplotlib colors pie-chart