Skip to content

Instantly share code, notes, and snippets.

@TomAugspurger
Created April 16, 2013 14:50
Show Gist options
  • Save TomAugspurger/5396549 to your computer and use it in GitHub Desktop.
Save TomAugspurger/5396549 to your computer and use it in GitHub Desktop.
Adding recession bars to matplotlib axes.
import pandas as pd
def add_rec_bars(ax, dates=None):
if dates is None:
dates = pd.read_csv('/Users/tom/bin/rec_dates.csv',
parse_dates=['Peak', 'Trough'])
for row in dates.iterrows():
x = row[1]
y1, y2 = ax.get_ylim()
ax.fill_between(x, y1=y1, y2=y2, alpha=.25, color='k')
return ax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment