Make ggplot graphs that look like the Wall Street Journal.
> install.packages("wsjplot")
> devtools::install_github("slee981/wsjplot")
> library(ggplot2)
> library(dplyr)
> `%>%` <- magrittr::`%>%`
> economics_long %>%
filter(variable %in% c("psavert", "uempmed")) %>%
ggplot(aes(date, value, color = variable)) +
geom_line() +
geom_hline(yintercept = 0, color = "darkgrey") +
scale_y_continuous(
labels = label_wsj(suffix = " M")
) +
scale_color_manual(
values = c("red", "blue"),
labels = c("Series 1", "Series 2")
) +
theme_wsj() +
labs(
title = "Some Economics Plot",
caption = "Source: Top secret.",
y = ""
)
theme_wsj()
: Sets the default theme. Use as you would any ggplot2::theme_choice()
.label_wsj()
: Formats y-axis ticks such that the top number on the graph
has the units, and the rest of the numbers are left visually clean. This
also removes the bottom most axis label by default, although this can be
overridden. Use in place of any scales::label_choice()
.$ git clone https://github.com/slee981/wsjplot.git
$ cd wsjplot
> library(devtools)
> load_all() # load exported functions into memory
> test() # run tests
> document() # update based on roxygen2 doc strings
> check() # full diagnostic tests
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.