Created
April 16, 2013 14:50
-
-
Save TomAugspurger/5396549 to your computer and use it in GitHub Desktop.
Adding recession bars to matplotlib axes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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