函数功能:在x轴上绘制定量数据的分布特征(用于连续数据,而柱状图用于离散数据)

调用签名:plt.hist(x)

x:在x轴上绘制箱体的定量数据输入值

代码实现:

import matplotlib.pyplot as plt
import numpy as np
import matplotlib as mpl

mpl.rcParams["font.sans-serif"]=["SimHei"]
mpl.rcParams["axes.unicode_minus"]=False

# 设置测试成绩
boxWeight = np.random.randint(0, 10, 100)

bins = range(0, 11, 1)

plt.hist(boxWeight, bins=bins, color="g", histtype="bar", rwidth=1, alpha=0.6)

plt.xlabel("箱子重量(kg)")
plt.ylabel("销售数量(个)")

plt.show()

python可视化---直方图hist()

相关文章:

  • 2022-12-23
  • 2021-07-21
  • 2021-08-07
  • 2022-12-23
  • 2021-09-21
  • 2021-10-31
  • 2021-07-07
  • 2022-01-17
猜你喜欢
  • 2022-01-02
  • 2022-01-20
  • 2022-12-23
  • 2021-06-21
  • 2022-01-24
  • 2022-12-23
  • 2021-12-29
相关资源
相似解决方案