Search
 
SCRIPT & CODE EXAMPLE
 

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()
Comment

PREVIOUS NEXT
Code Example
Python :: making a function wait in python 
Python :: how to use sum with range python 
Python :: pytorch detach 
Python :: convert string in list format to list python 
Python :: pandas change multiple column types 
Python :: save dictionary to file numpy 
Python :: declare numpy zeros matrix python 
Python :: simple http server python 
Python :: tkinter button command with arguments 
Python :: Get last “column” after .str.split() operation on column in pandas DataFrame 
Python :: python for loop in one line 
Python :: kaggle vs colab 
Python :: dataframe fill none 
Python :: binary to decimal in python 
Python :: python list comprehension with if 
Python :: random.shuffle 
Python :: Math Module log() Function in python 
Python :: python datetime weekday 
Python :: plt multiple figures to show 
Python :: register model in admin django 
Python :: python3 change file permissions 
Python :: sum of number digits python 
Python :: ParserError: Error tokenizing data. C error: Expected 1 fields in line 6, saw 3 
Python :: check pygame version 
Python :: python string match ignore case 
Python :: how to fill a list in python 
Python :: python ieee 754 converter 
Python :: password generator in python 
Python :: python read parquet 
Python :: index of max value of sequence python 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =