| nberShade.ggplot {tis} | R Documentation |
nberShade.ggplot is a method for shading recession areas
in a plot of class ggplot. It calls
nberDates to get x coordinates for the areas to be shaded
and then passes those coordinates along with its own arguments to
geom_rect to do the shading. It may also draw a vertical
line at the appropriate location if openShade is false and
its xrange is of an appropiate size.
## S3 method for class 'ggplot'
nberShade(gg = ggplot2::last_plot(), fill = "grey80", color = NA, size = 0.5,
alpha = 0.5, xrange = NULL, openShade = TRUE, ...)
gg |
A |
fill |
color to shade recessionary periods, passed to |
color |
The default ( |
size |
A number specifying how thick should the border lines be. Passed to |
alpha |
A number specifying how transparent the shaded regions should be. Passed to |
xrange |
Horizontal range over which recession shading should be
drawn. The default value |
openShade |
governs how |
... |
not used, present only to match generic |
Returns a ggplot object.
Recessions are dated by the Business Cycle Dating Committee of the National Bureau of Economic Research.
National Bureau of Economic Research. http://www.nber.org.
geom_rect, nberDates, nberShade
## Not run:
require("ggplot2")
ggp <- ggplot(aes(x=date, y=100*unemploy/pop), data=economics)
nberShade( ggp ) + xlim(as.Date("1967-01-01"), Sys.Date()) +
opts(legend.position="none") + geom_line() + theme_bw()
nberShade( ggp, fill = "yellow", color = "pink",
xrange = c("1969-01-01", "2008-02-01"), openShade = FALSE) +
opts(legend.position="none") + geom_line(size=1) + theme_bw()
## End(Not run)