matplotlib学习(长期更新)

绘制条形图

>>> import matplotlib.pyplot as plt
>>> a=['x','y']
>>> b=[1,2]
>>> plt.bar(a,b)
<BarContainer object of 2 artists>
>>> plt.show()
>>> plt.figure(),plt.bar(a,b,width=0.3)
(<Figure size 640x480 with 1 Axes>, <BarContainer object of 2 artists>)
>>> plkt.show()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'plkt' is not defined
>>> plt.show()

默认很宽,可以改一下宽度。

猜你喜欢

转载自blog.csdn.net/qq_44065334/article/details/113924522