python - matplotlib pie怎么設(shè)置alpha
問題描述
matplotlib.pyplot.bar有alpha這個參數(shù)但在pie里好像使用是會報錯,自帶的顏色太丑了!求大神賜教!
問題解答
回答1:因為沒有代碼,不太清楚你的實際情況,不過下列有一些例子,是有設(shè)罝了alpha值
polar_bar_demo.py 使用 bar.set_alpha(...)
matplotlib.patches.Patch 使用 fc=(0, 0, 1, 0.5)基本上是找對象設(shè)alpha值如XXX.set_aplha()或傳參數(shù)定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就可以了。
更多範(fàn)例見:Wedge
相關(guān)文章:
1. angular.js - webpack build后的angularjs路由跳轉(zhuǎn)問題2. java - web項目中,用戶登陸信息存儲在session中好 還是cookie中好,取決于什么?3. java - Activity中的成員變量被賦值之后,Activity被回收的時候內(nèi)存才會被釋放嗎4. Discuz! Q 有人用過嗎?5. 數(shù)組按鍵值封裝!6. 我寫的哪里有錯?請大神幫忙查看一下。7. 請求一個數(shù)據(jù)返回內(nèi)容為空或者錯誤如何再次請求幾次8. 使用list和each配合,的作業(yè),輸出一行后,如何換行9. php由5.3升級到5.6后,登錄網(wǎng)站,返回的是php代碼,不是登錄界面,各位大神有知道的嗎?10. 為什么bindClass訪問不了的?
