Histrogram: A Histogram Is A Graph Showing Frequency Distributions
Histrogram: A Histogram Is A Graph Showing Frequency Distributions
Histrogram: A Histogram Is A Graph Showing Frequency Distributions
#Creating dataset
a = np.array([22, 87, 5, 43, 56,73, 55, 54, 11,20, 51, 5, 79, 31,27])
# Creating histogram
# Show plot
plt.show()
the results of rolling 2 dice
Only has the values 2, 3, 4, 5, 6, 7, 8,
9, 10, 11 and 12
Histogram
Histogram(subplot)
It is accurate method for the graphical representation of numerical data distribution.
.It is a type of bar plot where X-axis represents the bin ranges while Y-axis gives information about frequency.
Creating a Histogram
function takes three arguments that describes the layout of the figure.
The layout is organized in rows and columns, which are represented bythe first and second argument.
#plot 1:
x = np.array([0, 1, 2, 3])
y = np.array([3, 8, 1, 10])
plt.subplot(2, 1, 1)
plt.plot(x,y)
#plot 2:
x = np.array([0, 1, 2, 3])
y = np.array([10, 20, 30, 40])
plt.subplot(2, 1, 2)
plt.plot(x,y)
plt.show()
Histogram
Customization of Histogram
Matplotlib provides a range of different methods to customize histogram.
matplotlib.pyplot.hist() function itself provides many attributes with the help of which we can modify a histogram
# Creating dataset
np.random.seed(23685752)
N_points = 10000
n_bins = 20
x = np.random.randn(N_points) # Creating distribution
y = .8 ** x + np.random.randn(10000) + 25
import numpy as np
y = np.sin(x ** 2)
fig, ax = plt.subplots()