HistoGrams
Viraj Vhatkar
Data Science Master's Student at University of New York, Buffalo || Data Analyst || Machine Learning || Data Visualization || Tableau Certified
What are Histograms?
Imagine we are in a forest full of different-sized creatures – from tiny bugs to tall trees. Now, we're curious about their heights, but there are just too many to keep track of.
So, we decided to measure them and create a special chart called a histogram. It's like sorting them into height groups, or "clubs," where similar-sized creatures hang out together. The taller the tower in a club, the more creatures of that height are in there.
Now, this chart helps us see which height groups have lots of creatures and which ones have just a few. It's like making a cool skyline of the forest, but with heights.
You notice that sometimes the towers lean to the left or right, showing if there are more short or tall creatures. It's like the forest telling us a little story about its residents.
Oh, and the width of the clubs is crucial. Too narrow, and each creature has its own club, making it messy. Too wide, and creatures get mixed up, losing the magic.
With this chart, we can even guess where the next creature might fall in height. If a tower is super tall in a club, there's a good chance the next creature will be around there.
And so, armed with our forest height chart, we explore the magical forest, discovering the heights of its incredible inhabitants.
Here, is a code for the basic code for the histogram.
#importing Libraries
import matplotlib.pyplot as plt
import numpy as np
# Generate a Synthetic height data
np.random.seed(42)
heights = np.random.normal(loc=270, scale=6, size=200)
plt.hist(heights, bins=np.arange(150, 200, 5), color='blue', edgecolor='black')
#the Plot
plt.title('Height_Distribution')
plt.xlabel('Height_(in_cm)')
plt.ylabel('No_of_People')
# Displaying the plot
plt.show()