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. java - Activity 进入后台再次传值?2. 前端 - flex布局采用space-around这种方法,但是最后一行如何让他左对齐?3. 前端 - 提问关于background-image不显示的问题4. chrome - linux系统下如何通过java获取客户端ip和mac地址?5. javascript - sublime已经安装了babel插件和sublimelinter-jshint为什么还是显示es6语法错误?6. angular.js - ng-include 会缓存html吗?7. css - 手机app中rem的基准值计算错误8. 前端 - 在webstrom上pull代码时出现错误?9. 小白问题getDay()10. java - git项目迁移到SVN怎么实现的?哪位大神指点指点

网公网安备