from scipy.io import loadmat
NYCdiseases = loadmat('NYCDiseases.mat') # loading a matlab file
chickenpox = np.sum(NYCdiseases['chickenPox'],axis=0)
mumps = np.sum(NYCdiseases['mumps'],axis=0)
measles = np.sum(NYCdiseases['measles'],axis=0)
In the snippet above we read the data from a Matlab file and summed the number of cases for each month. We are now ready to visualize our values using the function stackplot:
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
plt.stackplot(arange(12)+1,
[chickenpox, mumps, measles],
colors=['#377EB8','#55BA87','#7E1137'])
plt.xlim(1,12)
# creating the legend manually
plt.legend([mpatches.Patch(color='#377EB8'),
mpatches.Patch(color='#55BA87'),
mpatches.Patch(color='#7E1137')],
['chickenpox','mumps','measles'])
plt.show()
The result is as follows:
We note that the highest number of cases happens between January and Jul, also we see that measles cases are more common than mumps and chicken pox cases.
