submit your pull requests here
# based on the example found here
# https://github.com/matplotlib/matplotlib/blob/master/examples/showcase/xkcd.py
# Note: you'll need Humor-Sans (https://github.com/shreyankg/xkcd-desktop)
#installed to get the font right, otherwise it will default to Comic Sans.
# only necessary because I'm running on OS X
import matplotlib
matplotlib.use("Qt4Agg")
from matplotlib import pyplot as plt
import numpy as np
years = ['2001', '2003', '2005', '2007', '2009', '2011', '2013']
costs = ['$ 10,000', '$ 1,000', '$ 100', '$ 10', '$ 1', '$ 0.01']
with plt.xkcd(scale=1.11, length=100, randomness=4):
fig = plt.figure(figsize=(11, 6))
ax = fig.add_axes((0.1, 0.2, 0.8, 0.7))
# remove the ticks that show up on the top and right side
ax.yaxis.tick_left()
ax.xaxis.tick_bottom()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
# ticks labels
plt.xticks(xrange(0,200,31), years, size='large')
plt.yticks([10, 0, -10, -20, -30, -40], costs, size='large')
ax.set_ylim([-45, 10])
# first section: small slope
y_data = array(xrange(100,1,-1), dtype=float)/10.0
x_data = array(xrange(0,99,1))
# second section: aggressive decrease
y_data = append(y_data, array([y_data[-1]-2,-25]))
x_data = append(x_data, array([101, 125]))
# third section: small curve
y_data = append(y_data, array([-26, -27.2, -27.5, -27.9, -28, -29, -31, -32, -33, -34, -36]))
x_data = append(x_data, 11+array([115, 122, 129, 133, 136, 140, 142, 146, 147, 148, 149]))
# fourth section: small slope
y_data = append(y_data, array([-36,-39]))
x_data = append(x_data, 10+array([150,200]))
# annotations on the plot
plt.annotate('Cost per Raw Megabase of DNA Sequence', xy=(70, 1), xytext=(1, 6),
rotation=-10)
plt.annotate("Moore's Law (\"Computing power 2x every 2 years\")", xy=(69, 1), xytext=(69, 7),
rotation=-8)
plt.annotate(' Transition from\nSanger to "next-gen"\n sequencing',
xy=(100,7), arrowprops=dict(arrowstyle='->'), xytext=(75, 16))
# plot the main curve and then the dashed line
plt.plot(x_data, y_data, 'k')
plt.plot([5,200], [10, -5], 'k--', dashes=(30,17))
plt.ylabel('Cost', size=25, rotation=0)
# context for the x axis
fig.text(0.09, 0.12, 'Sept. 11 - Afghanistan War', rotation=-90, ha='center')
fig.text(0.11, 0.12, 'Drops of Jupiter', rotation=-90, ha='center')
fig.text(0.22, 0.12, 'Iraq war begins (most recent Iraq war)', rotation=-90, ha='center')
fig.text(0.39, 0.12, 'Pluto no longer a planet', rotation=-90, ha='center')
fig.text(0.44, 0.12, 'Umbrella by Rihanna', rotation=-90, ha='center')
fig.text(0.515, 0.12, 'Financial Crisis', rotation=-90, ha='center')
fig.text(0.58, 0.12, 'MJ Died :(', rotation=-90, ha='center')
fig.text(0.61, 0.12, 'COP 15', rotation=-90, ha='center')
fig.text(0.70, 0.12, 'Arab Spring', rotation=-90, ha='center')
# title
fig.suptitle('Timeline of sequencing cost, contextualized', fontsize=30, y=1.2)
plt.show()