# Customizing a graph with gray regions

I'd like to do a graph similar to this one with the gray regions to point the recessions in my graph. I have R and Excel and Stata, I'm simply trying to make it easy to distinguish the recessions by putting them in gray color, just like the picture here:

You don't really have to tell me every step for it, just lead me to where I can learn.

• Are you asking for code for some software? What software are you using? If that is representative of the data you want to show, you should be able to get such graphs, w/ recessions shaded automatically, from FRED. I suspect this question is almost certainly off-topic. Nov 19 '14 at 19:50
• You're going to have to give more details. It's easy enough to do such displays in a variety of software... but if for some reason you can't use that software, the solution's not much help to you -- here's an example I just generated. But if you don't use R, what good is that? Nov 19 '14 at 21:49
• I have R, ms excel and stata. I'm simply trying to plot the growth rate of my country, but I'd like to put the recessions in gray highlight. So people who read my work can easily distinguish them. That's pretty much what I need Glen_b. Nov 20 '14 at 1:09
• This is a strictly coding question, not a statistics question. Please add a reproducible example & we can migrate it for you. Nov 20 '14 at 18:57

You can do this in Stata like this using US recessions:

ssc install nbercycles
ssc install freduse
freduse GDP, clear
gen ym = mofd(daten)
tsset ym, monthly
nbercycles GDP if tin(1947m1,2014m7), file(graph.do) replace


The file graph.do will include detailed code about how to build such a graph by hand if you want to use a different country.

The graph will look like this: