1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| import pandas as pd import matplotlib.pyplot as plt
ao = pd.read_csv("AO.txt",sep='\s+',header=None, names=['year','month','AO']) ao_dec = ao[ao.month==12] ao_jan = ao[ao.month==1] ao_feb = ao[ao.month==2]
fig = plt.figure(figsize=(10, 8)) ax1 = fig.add_subplot(1,1,1) ax1.set_title('1979-2019 DJF AO Index')
ax1.bar(np.arange(2000,2020,1)-0.25,ao_dec.AO[50:],width=0.25,color='r',label='Dec') ax1.bar(np.arange(2000,2020,1),ao_jan.AO[50:],width=0.25,color='b',label='Jan') ax1.bar(np.arange(2000,2020,1)+0.25,ao_feb.AO[50:],width=0.25,color='g',label='Feb')
ax1.axhline(0,c='k')
ax1.legend() plt.show()
|