python matplotlib.pyplot 条形图详解

python matplotlib.pyplot 条形图详解

一、创建直方图

可以用bar函数来创建直方图

然后用show函数显示直方图

比如:

import matplotlib.pyplot as plt

x = [1, 4, 6, 8, 10]
y = [3, 5, 4, 7, 5]

plt.bar(x, y)
plt.show()

运行如下:

 

posted @ 2020-11-14 19:05  KevinLikesCoding  阅读(558)  评论(0)    收藏  举报