Python的matplotlib怎么在一张画布上,画两个饼状图啊?

Python的matplotlib怎么在一张画布上,画两个饼状图啊?,第1张

%matplotlib 祥搏inline

import matplotlib.pyplot as plt

# 121 > 1行2列第1个

fig1 = plt.subplot(121)

plt.pie([1,2,3])

# 谨芹祥122 >首肢 1行2列第2个

fig2 = plt.subplot(122)

plt.pie([10,5,5])

# 亦可以plt.subplot(221) 2行2列第1个

matplotlib

饼状图: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pie.html

保存图片: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.savefig.html

subplot_adjust: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.subplots_adjust.html

enumerate() 函数用于将一个可遍历的数雀粗铅据对象(如列表、元组或字符串)组合为一个索凳亩引序列,同时列出数据和数据下标,一般用在 for 循环当中。

语法顷好:

enumerate(sequence, [start=0])

参数:

sequence -- 一个序列、迭代器或其他支持迭代对象。

start -- 下标起始位置。

返回值:

返回 enumerate(枚举) 对象。

https://www.runoob.com/python/python-func-enumerate.html


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11985496.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存