We want to reproduce the Global Land-Ocean Temperature index plot below (available at this GISS website). Download the data this link and recreate the plot as closely as you can (don't worry about the two green points or matching the font). We've broken up this problem into steps to get you started. Feel free to follow them as you wish, or be a lone wolf and solve this on your own.
BONUS TASKS:
In [1]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
In [5]:
# I've chosen to save the "Annual means" and "5-year means" data sets into two separate sets of x- and y-values:
annual_means = np.genfromtxt('../Fig.A2.txt', dtype=float, skip_header=4, skip_footer=2, usecols=(0,1))
fiveyear_means = np.genfromtxt('../Fig.A2.txt', dtype=float, skip_header=6, skip_footer=4, usecols=(0,2))
In [6]:
plt.figure(figsize=(12,8))
plt.plot(annual_means[:,0], annual_means[:,1], 's-', color='k', lw=2, label="Annual Mean")
plt.plot(fiveyear_means[:,0], fiveyear_means[:,1], color='r', lw=2, label="5-year Running Mean")
plt.xlim(1880, 2015)
plt.ylim(-0.5, 0.7)
## Note: The way I have below is a brute-force method. If you do a little Googling you can
## find a more elegant solution using minor ticks. That having been said, this is probaly the
## easiest way to match the way their y axis labels EXACTLY.
myXTicks = np.arange(1880, 2020, 10)
myXTickLabels = ('1880', '', '1900', '', '1920', '', '1940', '', '1960', '', '1980', '', '2000')
plt.xticks(myXTicks, myXTickLabels, size=18)
myYTicks = np.arange(-0.5, 0.7, 0.1)
myYTickLabels = ('', '-.4', '', '-.2', '', '0.', '', '.2', '', '.4', '', '.6')
plt.yticks(myYTicks, myYTickLabels, size=18)
plt.grid(True)
plt.ylabel(r'Temperature Anomaly ($^\circ$C)', size=20)
plt.title('Global Land-Ocean Temperature Index', size=24, y=1.03)
plt.legend(loc=(0.1, 0.7), fontsize=20, numpoints=1, frameon=0)
Out[6]:
In [ ]: