How to add recession shading to a chart
Quick answer
Download FRED's monthly NBER recession indicator, USREC (1 in a recession, 0 otherwise), turn each run of 1s into a start and end date, and draw a shaded band behind your series for each pair. End each band on the first day of the month after the last flagged month, or every recession is drawn one month short. Say which of FRED's three dating conventions you used.
To add recession shading, download FRED's monthly NBER recession indicator, USREC (1 in a recession, 0 otherwise), turn each run of 1s into a start date and an end date, and draw a shaded band behind your series for each pair. Two details decide whether the bands are right: which of FRED's three dating conventions you pick, and where exactly each band ends.
Where the recession dates come from
US recession dates are set by the National Bureau of Economic Research, whose Business Cycle Dating Committee publishes a table of peak and trough months. It currently runs from 1854 to the April 2020 trough. NBER counts a recession as starting in the month after the peak and ending in the month of the trough.
FRED converts that table into 0/1 series you can download. The committee dates turning points with hindsight, so the zeros at the end of the series mean only that no recession has been declared so far.
Three conventions, three different bands
NBER names a peak month and a trough month, not days, so someone has to decide whether those two months are shaded. FRED publishes all three answers as separate monthly series:
series shades 2020 recession months flagged since 1948
USREC month after peak to trough month Mar-Apr 2020 124
USRECM peak month to trough month Feb-Apr 2020 136
USRECP peak month to month before trough Feb-Mar 2020 124FRED's notes call these the trough method, the midpoint method and the peak method. The USREC notes say the trough method is what FRED's own graphs use, and that the St. Louis Fed uses the midpoint method in its publications. The midpoint series flags one extra month for each of the 12 recessions since 1948. For 2020, the shortest recession in the table, the choice changes the band from two months to three.
USREC is the sensible default: it matches NBER's own description and what readers have already seen on FRED. Whichever you choose, name it in the chart note.
The off-by-one that shortens every band
Monthly data is stamped on the first of the month. USREC is 1 on 2020-03-01 and 2020-04-01. Shade from the first flagged date to the last flagged date and the band covers March 1 to April 1: one month of shading for a two-month recession. April 2020's data point, the 14.8% unemployment rate that is the highest in the series, lands on the band's edge instead of inside it.
The band should end on the first day of the month after the last flagged month, which here is May 1, 2020. FRED's daily version of the same indicator, USRECD, confirms the intent: it is 1 from March 1 through April 30, 2020, which is 61 days.
Python: recession bands with matplotlib
This reads the unemployment rate and USREC straight from FRED's CSV endpoint, builds the spans with the corrected end dates, and draws the bands behind the line:
import pandas as pd
import matplotlib.pyplot as plt
FRED = "https://fred.stlouisfed.org/graph/fredgraph.csv?id="
def fred(series_id):
return pd.read_csv(FRED + series_id, index_col=0, parse_dates=True)[series_id]
def recession_spans(flag):
"""flag: monthly 0/1 series stamped on the first of each month"""
flag = flag.astype(int)
change = flag.diff().fillna(flag.iloc[0])
starts = flag.index[change == 1]
ends = flag.index[change == -1] # first month back in expansion
if len(ends) < len(starts): # the series ends inside a recession
next_month = flag.index[-1] + pd.offsets.MonthBegin(1)
ends = ends.append(pd.DatetimeIndex([next_month]))
return list(zip(starts, ends))
unrate = fred("UNRATE")
spans = recession_spans(fred("USREC").loc[unrate.index[0]:])
fig, ax = plt.subplots(figsize=(10, 4))
for start, end in spans:
ax.axvspan(start, end, color="0.85", linewidth=0, zorder=0)
ax.plot(unrate.index, unrate.values, color="black", linewidth=1)
ax.set_ylabel("Unemployment rate, %")
fig.savefig("unrate_recessions.png", dpi=150)
print(len(spans), [(a.date().isoformat(), b.date().isoformat()) for a, b in spans[-2:]])Run on 25 November 2026 it prints 12 spans since 1948, the last two being 2008-01-01 to 2009-07-01 and 2020-03-01 to 2020-05-01. The spans are plain dates, so the same list shades a daily or weekly series without changes. The function also closes a band at the end of the data if the series is still inside a recession when it stops.
Spreadsheets and other tools
The same 0/1 column works anywhere. In a spreadsheet, add it as a second series, plot it as columns with no gap on a secondary axis fixed from 0 to 1, color it light gray and hide that axis. In a charting library, look for a band or rectangle annotation that takes two x values, and feed it the span list.
Design choices that keep the bands honest
Keep the shading behind the data, in a light neutral gray with no outline. Explain it once in the note ("Shaded areas are US recessions as dated by NBER") and leave it out of the legend. Do not shade periods you have labeled a recession yourself in the same gray as NBER's; if you must mark one, use a different color and say so.
Recession bands earn their place on series that move with the cycle: unemployment, credit spreads, and the yield curve spread, where the whole point is the lead time between an inversion and the next band.
Where Quadesto fits
Quadesto has a FRED connector, so the series and the recession indicator come from the same place. Connect them, describe the chart you want in plain words, and publish it as an embed for your newsletter or research page. Start free.