如何使用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')
可以按如下方式更改内部标签的颜色:
相关问题 更多 >
编程相关推荐