You are on page 1of 1

To create a Histogram using matplotlib library you have to install the package and its dependencies.

After installing the package you in the main program window I wrote the code to import the library.
Then I initialized the data of safety and security as an array. With the array wrote a code to plot the
array

1. #Import the library


2. import matplotlib.pyplot as plt
3. #initialize data as array
4. z = [16,34,60,23,56,53,47,8,35,7,7,57,59,23,41,56,23,5,62,40,34,21,
5. 32,14,48,57,9,28,20,55,21,59,59,39,23,44,50,23,36,24,57,10,17,21]
6. #draw the histogram
7. plt.hist(z, edgecolor="black", bins=8)
8. #define the title, x axis and y axis
9. plt.title("Histogram of Safety and Security")
10. plt.xlabel("SSPlt")
11. plt.xlabel("Bins")
12. plt.show()

Screenshot

You might also like