matplotlib pie怎么设置alpha

matplotlib.pyplot.bar有alpha这个参数但在pie里好像使用是会报错,自带的颜色太丑了!求大神赐教!

阅读 6.2k
1 个回答

因為沒有代碼,不太清楚你的實際情況,不過下列有一些例子,是有設罝了alpha值

見代碼

# Pie chart, where the slices will be ordered and plotted counter-clockwise:
labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'
sizes = [15, 30, 45, 10]
explode = (0, 0.1, 0, 0)  # only "explode" the 2nd slice (i.e. 'Hogs')

fig1, ax1 = plt.subplots()
patches, texts, autotexts = ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
        shadow=True, startangle=90)

for i, p in enumerate(patches):
    p.set_alpha(0.25*i)

plt.show()

patches/wedges set_alpha就可以了。

更多範例見:Wedge

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题