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

scoreT1 = np.random.randint(0, 100, 100)
scoreT2 = np.random.randint(0, 100, 100)

x = [scoreT1, scoreT2]
colors = ["#8dd3c7", "#bebada"]
labels = ["班级A", "班级B"]

bins = range(0, 101, 10)

plt.hist(x, bins=bins, color=colors, histtype="stepfilled", rwidth=10,
         stacked=True, label=labels)

plt.xlabel("测试成绩")
plt.ylabel("学生人数")

plt.title("不同班级的测试成绩的直方图")

plt.legend()

plt.show()

python可视化---直方图的不同形状

相关文章:

  • 2021-10-16
  • 2021-12-29
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2021-04-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
  • 2021-10-31
  • 2022-12-23
相关资源
相似解决方案