--- title: "Extending theme_doe" author: "Matthew Finkbeiner" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Extending theme_doe} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` This vignette provides examples of customising plot output using `theme_doe()`. ## Setup ```{r setup, message = FALSE, warning = FALSE} library(doestyle) library(dplyr) library(ggplot2) library(stringr) ``` ## Examples `doestyle` includes an example dataset: [public_schools], the NSW Public Schools Master dataset. ```{r data-setup, warning = FALSE} head(public_schools) ``` Typical use of `theme_doe()` and `scale_fill_doe()`: ```{r typical-use} public_schools |> filter(str_detect(Principal_network, "Connected Communities")) |> ggplot(aes(x = Principal_network, fill = Level_of_schooling)) + geom_bar(colour = "black", position = position_dodge(preserve = "single")) + theme_doe(base_family = "sans") + labs(y = "Schools", x = "") + scale_fill_doe() ``` Modify angle and colour of axis text, and orientation of legend, by adding arguments to the call to `theme_doe()`. See `ggplot2::theme()` for a complete list of arguments that can be passed to `theme_doe()`. ```{r extending-theme-doe} public_schools |> filter(str_detect(Principal_network, "Connected Communities")) |> ggplot(aes(x = Principal_network, fill = Level_of_schooling)) + geom_bar(colour = "black", position = position_dodge(preserve = "single")) + theme_doe(base_family = "sans", axis.text.x = element_text(color = 'blue', angle = 15, # add angle to x-axis labels hjust = 0.75, vjust = 1), axis.title.y = element_text(color = 'blue', angle = 0), # rotate y-axis title legend.direction = "vertical") + # stack legend text vertically labs(y = "Schools", x = "") + scale_fill_doe() ```