Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Imports:
grid,
gridExtra,
gridtext,
jsonlite,
lubridate,
magrittr,
purrr,
Expand Down
5 changes: 4 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Generated by roxygen2: do not edit by hand

export(.lwd)
export(GeomPandemics)
export(GeomPandemicsText)
export(GeomPointLast)
export(GeomRecessions)
export(GeomRecessionsText)
Expand All @@ -21,6 +23,7 @@ export(cmap_fill_highlight)
export(cmap_fill_race)
export(fetch_pal)
export(finalize_plot)
export(geom_pandemics)
export(geom_recessions)
export(geom_text_lastonly)
export(get_cmapplot_global)
Expand Down Expand Up @@ -48,6 +51,7 @@ importFrom(ggpubr,get_legend)
importFrom(glue,glue)
importFrom(glue,glue_collapse)
importFrom(gridExtra,arrangeGrob)
importFrom(jsonlite,fromJSON)
importFrom(lubridate,day)
importFrom(lubridate,decimal_date)
importFrom(lubridate,month)
Expand All @@ -61,4 +65,3 @@ importFrom(stringr,str_replace)
importFrom(stringr,str_trunc)
importFrom(tibble,tribble)
importFrom(utils,modifyList)
importFrom(utils,read.csv)
463 changes: 392 additions & 71 deletions R/geom_recessions.R

Large diffs are not rendered by default.

Binary file modified R/sysdata.rda
Binary file not shown.
6 changes: 6 additions & 0 deletions man/customproto.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 84 additions & 31 deletions man/geom_recessions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/update_recessions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vignettes/plots.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ The cmapplot package also includes two custom geoms that allow the user to easil

### Include US recessions as a backdrop

The function `geom_recessions()`, allows for the addition of rectangles (and text, if desired) representing US economic recessions. Similar to the `hline` example above, `geom_recessions()` should be added before the plot's primary geom (`geom_line()`) so that lines are drawn on top of recession rectangles.
The function `geom_recessions()`, allows for the addition of rectangles (and text, if desired) representing US economic recessions. Similar to the `hline` example above, `geom_recessions()` should be added before the plot's primary geom (`geom_line()`) so that lines are drawn on top of recession rectangles. A complementary `geom_pandemics()` function allows for similar portrayals of the COVID-19 pandemic and other potential future pandemics.

`ggplot()` always draws geoms *on top* of base plot elements like gridlines. The default fill and alpha values for `geom_recessions()` are the most transparent way possible to achieve CMAP palette color `#002d49` when drawn on a white background — thus impacting the color of the gridlines as little as possible.

This function relies on the National Bureau of Economic Research's definitions of recessions. Details on how to update these dates, as well as how to provide your own, can be found in `geom_recessions()` and `update_recessions()`. If the most recent recession has not yet been declared over (as is the case in June 2021), the function will default to displaying this ongoing recession from its beginning through the end of the visualized data. If this is not desired (for example, if the visualization is of a projection far into the future), users can remove this ongoing recession by setting `show_ongoing = FALSE`.
The recession function relies on the National Bureau of Economic Research's definitions of recessions. Details on how to update these dates, as well as how to provide your own, can be found in `geom_recessions()` and `update_recessions()`. If the most recent recession has not yet been declared over (as is the case in June 2021), the function will default to displaying this ongoing recession from its beginning through the end of the visualized data. If this is not desired (for example, if the visualization is of a projection far into the future), users can remove this ongoing recession by setting `show_ongoing = FALSE`.

```{r recessions, message = FALSE}
q <- ggplot(data = df,
Expand Down