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 ...