label_wsj: Label plots like the wall street journal i.e. display the...

Description Usage Arguments Examples

View source: R/label_wsj.R

Description

Label plots like the wall street journal i.e. display the units only on the top tick of the graph

Usage

1
2
3
4
5
6
7
8
label_wsj(
  prefix = "$",
  suffix = "",
  rm.bottom = TRUE,
  accuracy = NA,
  reverse = FALSE,
  ...
)

Arguments

prefix

character, the unit label to prefix on the max number of the y-axis

suffix

character, the unit label to append on the max number of the y-axis

rm.bottom

logical, remove the lowest number?

accuracy

double, the precision for labels e.g. 1, 0.1, or 0.01

reverse

logical, put label on the smallest tick instead of the largest?

...

args passed to scales::label_comma(...)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
library(ggplot2)
`%>%` <- magrittr::`%>%`

plt <- economics_long %>%
  dplyr::filter(variable %in% c("psavert", "uempmed")) %>%
  ggplot(aes(date, value, color = variable)) +
  geom_line() +
  scale_y_continuous(
      labels = label_wsj(prefix = "$", suffix = " %")
  ) +
  theme_wsj() +
  labs(
    title = "Some Economics Plot",
    caption = "Source: Top secret."
  )

slee981/wsjplot documentation built on March 20, 2021, 3:09 p.m.