A collection of ggplot2 themes and functions for use in PTT.
Install from github:
# install.packages("devtools")
devtools::install_github("pttry/ggptt")
Prepartions for introduction:
# Install and load packages
# install.packages(c("ggptt", "dplyr", "tidyr", "scales"))
library(ggptt)
library(dplyr)
# Clear possible settings
unset_ptt()
# data for examples
pdat <- economics %>%
select(date, psavert, uempmed) %>%
tidyr::gather(vars, values, -date)
ggptt
will also load ggplot2
.
scales::show_col(ptt_pal(6))
scales::show_col(vnk_pal(4))
scale_colour_ptt()
and scale_fill_ptt()
p <- ggplot(pdat, aes(x = date, y = values, colour = vars)) +
geom_line()
p
p + scale_colour_ptt()
p + theme_ptt()
set_ptt()
sets PTT theme and colours. unset_ptt()
could be used to undo ggptt settings.
set_ptt()
p
Also theme_map()
for maps.
p + the_legend_bot()
p + the_title_blank()
p + the_title_blank(c("x", "l"))
p + the_x45()
p + scale_x_date(labels = no_century)
# Percents
pdat2 <- pdat %>% mutate(values = values/100)
p %+% pdat2 + scale_y_continuous(labels = percent_comma)
# comma
p %+% pdat2 + scale_y_continuous(labels = deci_comma)
p + geom_h0()
grid_arrange_shared_legend(p, p + geom_h0(), ncol = 2)
p + scale_y_continuous(breaks = extra_breaks(17))