用python在一个图中显示画两个hist图:

import random
import numpy
from matplotlib import pyplot

x = [random.gauss(3,1) for _ in range(400)]
y = [random.gauss(4,2) for _ in range(400)]

bins = numpy.linspace(-10, 10, 100)

pyplot.hist(x, bins, alpha=0.5, label='x')
pyplot.hist(y, bins, alpha=0.5, label='y')
pyplot.legend(loc='upper right')
pyplot.show()

 

结果显示:

在一张图中显示两个hist图(python)

相关文章:

  • 2021-12-16
  • 2021-11-02
  • 2021-12-24
  • 2021-07-17
  • 2021-06-03
  • 2022-01-02
  • 2021-05-31
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-26
  • 2021-08-01
  • 2021-04-06
  • 2021-06-13
  • 2021-08-05
  • 2021-08-01
相关资源
相似解决方案