Skip to content

Instantly share code, notes, and snippets.

@davmlaw
Created July 4, 2014 14:18
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 davmlaw/5a10eea46d20caa19227 to your computer and use it in GitHub Desktop.
Save davmlaw/5a10eea46d20caa19227 to your computer and use it in GitHub Desktop.
Future Of Humanity Plot
#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
LATEX_BASELINE = 0.1
FUNDIES = 20
BIRTH_CONTROL_INVENTION=0.1
FUNDIE_ARROW_OFFSET = 0.1
plt.xkcd()
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
plt.xticks([])
plt.yticks([])
plt.suptitle("The Future of the Human Race", fontsize=24)
plt.xlabel('Time', fontsize=20)
plt.ylabel('Percent of population', fontsize=20)
x = np.arange(-10, 10, 0.01)
curve = np.arctan(x)
curve += abs(np.min(curve))
y = np.empty(len(x))
y.fill(LATEX_BASELINE)
birth_control_start = len(x) * BIRTH_CONTROL_INVENTION
y[birth_control_start:] += curve[:-birth_control_start]
scaled_top = 100.0 * np.max(y) / (100.0 - FUNDIES)
ax.set_ylim([0, scaled_top])
ax.annotate("Invention of birth control",
(x[birth_control_start], y[birth_control_start] + 0.01), # Pad to not intersect line
xycoords='data',
xytext=(-30, 60), textcoords='offset points',
arrowprops=dict(arrowstyle="->",
connectionstyle="angle3,angleA=0,angleB=80"),
)
arrow_offset = int(FUNDIE_ARROW_OFFSET * len(x))
y_arrow = y[-arrow_offset]
plt.annotate('', xy=(x[-arrow_offset], y_arrow), xycoords = 'data',
xytext = (x[-arrow_offset], scaled_top), textcoords = 'data',
arrowprops = {'arrowstyle':'<->'})
half = (y_arrow + scaled_top) / 2.0
plt.annotate('Religious\nFundamentalists', xy=(x[-arrow_offset], half), xycoords = 'data',
xytext = (-15, 0), textcoords = 'offset points', ha='right', va='center')
plt.annotate('bioinfomofo.blogspot.com', xy=(.9, 0), xycoords='figure fraction',
horizontalalignment='right', verticalalignment='bottom')
plt.plot(x, y, label='Latex Allergy')
ax.legend(loc='upper left')
plt.savefig("future_of_humanity.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment