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 plot and histogram for us to see the distribution of VacationHours
across different job titles for AdventureWorks.
Annotating in Python
One of the nice features with matplotlib
is the ability to annotate graphs to help guide users to areas of...