--- title: "Available themes in INBOtheme" author: "Thierry Onkelinx" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Available themes in INBOtheme} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- # Introduction This vignette focuses on the available `ggplot2` themes in `INBOtheme`. They mainly control the looks of the axes, background, legend, ... Some themes also impact the schemes when using a colour or fill along a variable. We illustrate that in `vignette("colour", package = "INBOtheme")`. ## Important The `ggplot2` package must be loaded prior to `INBOtheme`. Loading `INBOtheme` sets `inbo_theme()` as default theme and `inbo_steun_blauw` as default colour for the `geoms`. Note how we use `theme_set()` and `switch_colour()`. This applies the theme and colour to all subsequent plots without the need to change the `ggplot2` code. ### Using the default theme from `INBOtheme` Add the following code after loading the `ggplot2` or `tidyverse` package and before creating the `ggplot2` plots. ```{r eval = FALSE, echo = TRUE} library(INBOtheme) ``` In case you need to change the default font size or background add the code below after loading the package. ```{r eval = FALSE, echo = TRUE} theme_set(theme_inbo(base_size = 12, transparent = FALSE)) ``` ### Using a non-default theme from `INBOtheme` Add the following code after loading the `ggplot2` or `tidyverse` package and before creating the `ggplot2` plots. ```{r eval = FALSE, echo = TRUE} library(INBOtheme) theme_set(theme_vlaanderen2015(base_size = 12, transparent = FALSE)) switch_colour(vl_darkyellow) ``` ```{r eval = FALSE, echo = TRUE} library(INBOtheme) theme_set(theme_elsevier(base_size = 12, transparent = FALSE)) switch_colour("black") ``` # Prepare the code and data ```{r knitr, include = FALSE} library(knitr) opts_chunk$set( echo = FALSE, message = FALSE, warning = FALSE ) base_size <- ifelse(opts_knit$get("rmarkdown.pandoc.to") == "latex", 7, 12) ``` ```{r initialise, echo = TRUE} library(ggplot2) library(INBOtheme) ``` ```{r prepare-data, echo = TRUE} # Prepare the data for the figures d <- data.frame( x = "Sphinx of black quartz, judge my vow", y = "Sphinx of\nblack quartz,\njudge my vow" ) data("esoph") cancer <- esoph cancer$Age <- cancer$agegp cancer$Alcohol <- cancer$alcgp cancer$Tabacco <- cancer$tobgp cancer$Proportion <- cancer$ncases / (cancer$ncases + cancer$ncontrols) ``` # Default: `theme_inbo()` ## `theme_inbo()` with default background ```{r set_theme_inbo, echo = TRUE, eval = FALSE} theme_set(theme_inbo(base_size = 12)) switch_colour(inbo_steun_blauw) ``` ```{r set_theme_inbo2, echo = FALSE} theme_set(theme_inbo(base_size = base_size)) switch_colour(inbo_steun_blauw) ``` ```{r inbo-plots, results = "asis"} rmd <- knit_expand("child/_themes_test_figures.Rmd", theme = "inbo") md <- knit(text = rmd, quiet = TRUE) cat(md) ``` ## `theme_inbo()` with transparent background ```{r set_theme_inbo_transparant, echo = TRUE, eval = FALSE} theme_set(theme_inbo(base_size = 12, transparent = TRUE)) switch_colour(inbo_steun_blauw) ``` ```{r set_theme_inbo_transparant2, echo = FALSE} theme_set(theme_inbo(base_size = base_size, transparent = TRUE)) switch_colour(inbo_steun_blauw) ``` ```{r inbo-transparant-plots, results = "asis"} rmd <- knit_expand("child/_themes_test_figures.Rmd", theme = "inbo-tr") md <- knit(text = rmd, quiet = TRUE) cat(md) ``` # `theme_vlaanderen2015()` ## `theme_vlaanderen2015()` with default background ```{r set_theme_vlaanderen2015, echo = TRUE, eval = FALSE} theme_set(theme_vlaanderen2015(base_size = 12)) switch_colour(vl_darkyellow) ``` ```{r set_theme_vlaanderen20152, echo = FALSE} theme_set(theme_vlaanderen2015(base_size = base_size)) switch_colour(vl_darkyellow) ``` ```{r vlaanderen-plots, results = "asis"} rmd <- knit_expand("child/_themes_test_figures.Rmd", theme = "vlaanderen") md <- knit(text = rmd, quiet = TRUE) cat(md) ``` ## `theme_vlaanderen2015()` with transparent background ```{r set_theme_vlaanderen2015_transparant, echo = TRUE, eval = FALSE} theme_set(theme_vlaanderen2015(base_size = 12, transparent = TRUE)) switch_colour(vl_darkyellow) ``` ```{r set_theme_vlaanderen2015_transparant2, echo = FALSE} theme_set(theme_vlaanderen2015(base_size = base_size, transparent = TRUE)) switch_colour(vl_darkyellow) ``` ```{r vlaanderen-transparant-plots, results = "asis"} rmd <- knit_expand("child/_themes_test_figures.Rmd", theme = "vlaanderen-tr") md <- knit(text = rmd, quiet = TRUE) cat(md) ``` # `theme_elsevier()` Note that `theme_elsevier()` uses a base font size of 7. Use that default when preparing plots for a paper. ```{r set_theme_elsevier, echo = TRUE, eval = FALSE} theme_set(theme_elsevier(base_size = 12)) switch_colour("black") ``` ```{r set_theme_elsevier2, echo = FALSE} theme_set(theme_elsevier(base_size = base_size)) switch_colour("black") ``` ```{r elsevier-plots, results = "asis"} rmd <- knit_expand("child/_themes_test_figures.Rmd", theme = "elsevier") md <- knit(text = rmd, quiet = TRUE) cat(md) ```