O'Reilly logo

Practical Business Intelligence by Ahmed Sherif

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Combining a histogram with a normal distribution plot

We now have a histogram and a normal distribution plot individually, but it would be nice if we could visualize both them on one graph with the same scales. This can easily be done by referencing both plots in a single cell and then using the plt.show() function just once after both plots have been called:

plt.hist(VacationHours, normed = True) # plotting histogram 
plt.plot(VacationHours, normal_distribution_curve, color = "orange") #plotting normal curve 
plt.title("Vacation Hours") #Assign title 
plt.xlabel("Hours") #Assign x label 
plt.ylabel("Count") #Assign y label 
plt.show() 

The output of the combined plots can be seen in the following screenshot:

We now have a combined normal distribution ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required