Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

matplotlib draw two histograms on same image

# credit to the Stack overflow user in the source link
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()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #matplotlib #draw #histograms #image
ADD COMMENT
Topic
Name
4+6 =