Skip to content

Instantly share code, notes, and snippets.

@riceissa
Last active January 21, 2017 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riceissa/72025b02f89d1153d91ea3edecf57ecf to your computer and use it in GitHub Desktop.
Save riceissa/72025b02f89d1153d91ea3edecf57ecf to your computer and use it in GitHub Desktop.
polio cases plot

Files:

  • README.md: This readme.
  • plot.py: Python 3 script for plotting the data.
  • polio.txt: International Wild Poliovirus Cases by Year, from 1.
#!/usr/bin/python3
import csv
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.inset_locator import inset_axes, mark_inset
ys = []
rs = []
reader = csv.reader(open('polio.tsv', newline=''), delimiter='\t')
next(reader) # skip top row
for row in reader:
year = int(row[0])
recorded = int(row[2].replace(",", ""))
ys.append(year)
rs.append(recorded)
fig, ax = plt.subplots()
ax.plot(ys, rs)
axins = inset_axes(ax, width="60%", height=2.7, loc=1)
axins.plot(ys, rs)
axins.set_xlim(2000, 2016)
axins.set_ylim(0, 2100)
mark_inset(ax, axins, loc1=3, loc2=4, fc="none", ec="0.5")
plt.show()
Year Estimated Recorded
1975 49,293
1980 400,000 52,552
1985 38,637
1988 350,000 35,251
1990 23,484
1993 100,000 10,487
1995 7,035
2000 719
2001 483
2002 1,918
2003 784
2004 1,255
2005 1,979
2006 1,997
2007 1,315
2008 1,651
2009 1,604
2010 1,352
2011 650
2012 223
2013 416
2014 359
2015 74
2016 37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment