Skip to content

Instantly share code, notes, and snippets.

@mathDR
Created July 5, 2018 20:21
Show Gist options
  • Save mathDR/0a07dcab0621bde138ac99734292ed5a to your computer and use it in GitHub Desktop.
Save mathDR/0a07dcab0621bde138ac99734292ed5a to your computer and use it in GitHub Desktop.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn
from scipy.signal import savgol_filter
pop_data = pd.read_csv('world_population.csv') # Note, this is the file located at https://github.com/Brideau/GeospatialLineGraphs/tree/master/GeneratedData
data = pop_data.values
data = data.transpose()
data_max = data.max()
fig, ax = plt.subplots(figsize=(22,14),frameon=False)
threshold = 0.1
for row_index in range(data.shape[0]):
yvals = data[row_index,:]/data_max * 100
y = savgol_filter(yvals, 7, 4)
y[y<0]=0
x = np.array(list(range(y.shape[0])))
plt.plot(x, y + data.shape[0]-row_index,color='k',zorder=row_index)
ax.fill_between(x,data.shape[0]-row_index, y + data.shape[0]-row_index, where=y>threshold, color='r',zorder=row_index)
plt.axis('off');
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment