python - matplotlib pie怎么設(shè)置alpha
問題描述
matplotlib.pyplot.bar有alpha這個(gè)參數(shù)但在pie里好像使用是會(huì)報(bào)錯(cuò),自帶的顏色太丑了!求大神賜教!
問題解答
回答1:因?yàn)闆]有代碼,不太清楚你的實(shí)際情況,不過下列有一些例子,是有設(shè)罝了alpha值
polar_bar_demo.py 使用 bar.set_alpha(...)
matplotlib.patches.Patch 使用 fc=(0, 0, 1, 0.5)基本上是找對(duì)象設(shè)alpha值如XXX.set_aplha()或傳參數(shù)定facecolor fc值時(shí)給四位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. mysql - 如何減少使用或者不用LEFT JOIN查詢?2. python - Scrapy存在內(nèi)存泄漏的問題。3. Python爬蟲如何爬取span和span中間的內(nèi)容并分別存入字典里?4. python - 我在使用pip install -r requirements.txt下載時(shí),為什么部分能下載,部分不能下載5. 視頻文件不能播放,怎么辦?6. mysql - 分庫(kù)分表、分區(qū)、讀寫分離 這些都是用在什么場(chǎng)景下 ,會(huì)帶來哪些效率或者其他方面的好處7. mysql - jdbc的問題8. html5 - H5 audio 微信端 在IOS上不能播放音樂9. python - 編碼問題求助10. mysql - 千萬級(jí)數(shù)據(jù)的表,添加unique約束,insert會(huì)不會(huì)很慢?
