Overlaying a line graph and an area graph: adding recession bars to a time series I am trying to reconstruct a time series graphs from FRED: https://fred.stlouisfed.org/series/LABSHPUSA156NRUG using Python. However, I am unable to get a clean figure where the time series is overlaid with the area graph representing the recession bars.
I am quite new to python so it's been frustrating to find a simple reason why my attempts are not working.
I have attempted this two ways.
My first attempt looks like this:
fig, ax = plt.subplots()
ls_data.plot.line(ax=ax, figsize=(8,5), x='Date', color=blue)
rec_data.plot.area(ax=ax, figsize=(8,5), x='Date', alpha=0.5, color=gray)
plt.ylim(0.59,0.65)

And produces the following perplexing mess: 
My second attempt goes for the &quot;ax2 = ax1.twinx()&quot; route
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()

ls_data.plot.line(figsize=(8,5), x='Date', color=blue)
rec_data.plot.area(figsize=(8,5), x='Date', alpha=0.5, color=gray)

However this produces two separate figures instead.


One possible issue is that the x-values for the labor share are plotted in individual years whereas the x-values for recession are plotted in months. But based on the second attempt, it looks like the graphs should overlay smoothly but then I'm liable to get the same result as in my first attempt. Would transforming the recession data provide a fix?
Edit: The data for recession dates are available here. https://fred.stlouisfed.org/series/USREC#:~:text=For%20daily%20data%2C%20the%20recession,the%20month%20of%20the%20trough.
Using the data from FRED for both labour data and recession data and slight adjustments to your code I think I get the result you want:
import pandas as pd
import matplotlib.pyplot as plt

# read in data
rec_data = pd.read_csv(&quot;USREC.csv&quot;)
ls_data = pd.read_csv(&quot;LABSHPUSA156NRUG.csv&quot;)

# make sure date columns are actual dates
rec_data[&quot;DATE&quot;] = pd.to_datetime(rec_data[&quot;DATE&quot;])
ls_data[&quot;DATE&quot;] = pd.to_datetime(ls_data[&quot;DATE&quot;])

# create plot
fig, ax = plt.subplots()
ls_data.plot.line(ax=ax, figsize=(8, 5), x='DATE', color=&quot;blue&quot;)
rec_data.plot.area(ax=ax, figsize=(8, 5), x='DATE', alpha=0.5, color=&quot;gray&quot;)
plt.xlim(&quot;1950-01-01&quot;, &quot;2020-01-01&quot;)
plt.ylim(0.58, 0.65)