我是靠谱客的博主 饱满豌豆,这篇文章主要介绍matplotlib之饼状图,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
import matplotlib.pyplot as plt labels = 'A', 'B', 'C', 'D' fracs = [35, 20, 45, 10] plt.pie(x=fracs, labels=labels) plt.show()

圆形饼图

复制代码
1
2
3
4
5
6
7
8
9
import matplotlib.pyplot as plt labels = 'A', 'B', 'C', 'D' fracs = [35, 20, 45, 10] plt.axes(aspect=1) plt.pie(x=fracs, labels=labels) plt.show()

比例显示

复制代码
1
2
3
4
5
6
7
8
9
import matplotlib.pyplot as plt labels = 'A', 'B', 'C', 'D' fracs = [35, 20, 45, 10] plt.axes(aspect=1) plt.pie(x=fracs, labels=labels, autopct='%.0f%%') plt.show()

突出显示

复制代码
1
2
3
4
5
6
7
8
9
10
import matplotlib.pyplot as plt labels = 'A', 'B', 'C', 'D' fracs = [35, 20, 45, 10] explode = [0, 0.05, 0.08, 0] plt.axes(aspect=1) plt.pie(x=fracs, labels=labels, autopct='%.0f%%', explode=explode) plt.show()

添加阴影

复制代码
1
2
3
4
5
6
7
8
9
10
import matplotlib.pyplot as plt labels = 'A', 'B', 'C', 'D' fracs = [35, 20, 45, 10] explode = [0, 0.05, 0.08, 0] plt.axes(aspect=1) plt.pie(x=fracs, labels=labels, autopct='%.0f%%', explode=explode, shadow=True) plt.show()

 

最后

以上就是饱满豌豆最近收集整理的关于matplotlib之饼状图的全部内容,更多相关matplotlib之饼状图内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部