It’s currently a work-in-progress (version 0.2), with planned improvements including:
- Wrappers around options, so they are less verbose (e.g.
- Documentation and website.
- Better automated placement of legend and text labels.
- Better testing of different OSes and chart types.
- Document that fonts and other options can be changed through
(Also see here for a self-contained script)
library(fedplot) ggplot(plotdata, aes(x = Date, y = value, group=source)) + geom_recessions() geom_hline(yintercept = 0, linewidth = getOption("fedplot.linewidth_adj"), linejoin = "mitre", lineend = "round") + geom_line(aes(color=source, linewidth=source), na.rm = T, linejoin = "mitre", lineend = "round") + labs(y = "12-month percent change") + scale_x_date(minor_breaks=seq(from=as.Date("2003-01-01"), to=as.Date("2023-01-01"), by="1 years"), breaks=seq(from=as.Date("2004-06-30"), to=as.Date("2023-06-30"), by="3 years"), date_labels="%Y", expand=expansion(mult=.10)) + scale_y_continuous(sec.axis = dup_axis(), breaks = seq(-25, 25, by=5), limits = c(-25, 25), expand = expansion(mult=0), labels = scales::label_number(style_negative = "minus")) + annotate_last_date(nudge_y = -3, nudge_x = 0) + theme_fed(legend_position = c(.55, .5)) save_plot('my-figure', size='narrow', extension='png')
To install or update
- Add documentation and pkgdown website
line.Rinto a vignette.
- Add examples for bar charts
- Add wrappers to the geom_hline (maybe set as an option to
theme_fed), to the scale_* functions, and to geom_line (so it uses the group aes into its color and linewidth aes, plus the other options).
- Ensure that certain geometries (e.g. recession bars) are always in the background, independently on the order in which they were added. This can be achieved with e.g.
- Recession bars as well as some design ideas are based on the great
cmapplotlibrary mantained by the Chicago Metropolitan Agency for Planning.
ggplot_addmagic: https://www.simonpcouch.com/blog/ggplot-pipe-plus/ , https://yutani.rbind.io/post/2017-11-07-ggplot-add/
- Editing the DESCRIPTION file: https://r-pkgs.org/description.html , https://kbroman.org/pkg_primer/pages/depends.html , https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-Dependencies