在饼图中更改标签和测试颜色

Changing the label, and test colour in a pie chart

我用过这个代码:

winner_percent=games_df.winner.value_counts(normalize=True)*100
winner_percent.plot(
    kind='pie',
    title='Proportion of piece colour effect on the game result',
    autopct="%.1f%%",
    colors=['white','black','grey'],
    explode=(0, 0.08, 0),
    figsize=(10,7),
    wedgeprops={"edgecolor":"k",'linewidth': 2, 'linestyle': 'solid', 'antialiased': True},
    textprops={'color':"b"}

)
plt.legend()

我得到的图表是:

能否指导我实现:

预先感谢您的帮助。

将所有内容绘制为黑色并手动将两个百分比更改为白色:

winner_percent= pd.Series({'white': 49.9, 'black': 45.4, 'draw': 4.7}, name='Winner')
ax = winner_percent.plot(
        kind='pie',
        title='Proportion of piece colour effect on the game result',
        autopct="%.1f%%",
        colors=['white','black','grey'],
        explode=(0, 0.08, 0),
        figsize=(10,7),
        wedgeprops={"edgecolor":"k",'linewidth': 2, 'linestyle': 'solid', 'antialiased': True},
        textprops={'color':"k"}

    )

ax.texts[3].set_color('w')
ax.texts[5].set_color('w')
plt.legend()

输出:

您可以通过以下方式查看文本列表:

>>> ax.texts
[Text(0.0034557017432522113, 1.099994571861817, 'white'),
 Text(0.001884928223592115, 0.5999970391973546, '49.9%'),
 Text(-0.17726600554646288, -1.1666090876028703, 'black'),
 Text(-0.10215329133185996, -0.6722832030253828, '45.4%'),
 Text(1.0880307327465517, -0.1618305428496183, 'draw'),
 Text(0.5934713087708463, -0.08827120519070088, '4.7%')]