1import matplotlib.pyplot as plt
2data = [1.7,1.8,2.0,2.2,2.2,2.3,2.4,2.5,2.5,2.5,2.6,2.6,2.8,
3 2.9,3.0,3.1,3.1,3.2,3.3,3.5,3.6,3.7,4.1,4.1,4.2,4.3]
4#this histogram has a range from 1 to 4
5#and 8 different bins
6plt.hist(data, range=(1,4), bins=8)
7plt.show()
1import matplotlib.pyplot as plt
2
3x = [1,1,2,3,3,5,7,8,9,10,
4 10,11,11,13,13,15,16,17,18,18,
5 18,19,20,21,21,23,24,24,25,25,
6 25,25,26,26,26,27,27,27,27,27,
7 29,30,30,31,33,34,34,34,35,36,
8 36,37,37,38,38,39,40,41,41,42,
9 43,44,45,45,46,47,48,48,49,50,
10 51,52,53,54,55,55,56,57,58,60,
11 61,63,64,65,66,68,70,71,72,74,
12 75,77,81,83,84,87,89,90,90,91
13 ]
14
15plt.hist(x, bins=10)
16plt.show()
17
1import matplotlib.pyplot as plt
2 data = [1.7,1.8,2.0,2.2,2.2,2.3,2.4,2.5,2.5,2.5,2.6,2.6,2.8,
3 2.9,3.0,3.1,3.1,3.2,3.3,3.5,3.6,3.7,4.1,4.1,4.2,4.3]
4 plt.hist(data)
5 plt.title('Histogram of Data')
6 plt.xlabel('data')
7 plt.ylabel('count')
1# Import packages
2import matplotlib.pyplot as plt
3%matplotlib inline
4
5# Create the plot
6fig, ax = plt.subplots()
7
8# Plot the histogram with hist() function
9ax.hist(x, edgecolor = "black", bins = 5)
10
11# Label axes and set title
12ax.set_title("Title")
13ax.set_xlabel("X_Label")
14ax.set_ylabel("Y_Label")
1import pyplot from matplotlib as plt
2plt.hist(x, bins=None, range=None, density=False, weights=None, cumulative=False, bottom=None, histtype='bar', align='mid', orientation='vertical', rwidth=None, log=False, color=None, label=None, stacked=False, *, data=None, **kwargs)