python - matplotlib pie怎么設置alpha
問題描述
matplotlib.pyplot.bar有alpha這個參數但在pie里好像使用是會報錯,自帶的顏色太丑了!求大神賜教!
問題解答
回答1:因為沒有代碼,不太清楚你的實際情況,不過下列有一些例子,是有設罝了alpha值
polar_bar_demo.py 使用 bar.set_alpha(...)
matplotlib.patches.Patch 使用 fc=(0, 0, 1, 0.5)基本上是找對象設alpha值如XXX.set_aplha()或傳參數定facecolor fc值時給四位tuple。
見代碼
# 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
相關文章:
1. 極光推送 - Android app消息推送 百度 極光 個推 信鴿哪個好一些?2. 什么是前后端分離?用vue angular等js框架就能實現前后分離了嗎?3. ddos - apache日志很多其它網址,什么情況?4. java - Mybatis關聯查詢5. html - css中怎么命名顏色比較好?6. html - chrome 下 transiton translateX(10px) 后字體變化7. java - 為什么第一個線程已經釋放了鎖,第二個線程卻不行?8. javascript - avalon使用:duplex設置select默認option的bug9. android - 百度地圖加載完成監聽10. 這是什么情況???
