---
title: Template Title
subtitle: Subtitle
author: Lennart Klein
date: last-modified
format:
scl-html: default
execute:
cache: true
freeze: auto
warning: false
---
# Setup
```{r setup}
#| echo: true
#| output: false
library (tidyverse)
```
```{r theme}
#| eval: true
#| echo: false
scl_colors <- c ("logo" = "#3653C8" , "font" = "#243937" , "#0B2E6E" , "#0F4AB2" )
theme_scl <- function (
base_size = 12 ,
base_family = "" ,
plot_title_size = 20 ,
plot_title_color = scl_colors["logo" ]) {
ggplot2:: theme_minimal (base_size = base_size, base_family = base_family) +
theme (
plot.background = element_rect (colour = "white" ), # removed by minimal
text = element_text (color = "black" ),
axis.text = element_text (color = "black" ), # break labels
axis.title = element_text (color = "black" , size = base_size), # axis labels
axis.line = element_line (),
legend.text = element_text (color = "black" ),
plot.title = element_text (color = plot_title_color),
plot.caption = element_text (color = scl_colors["font" ], size = 9 , hjust = 0 )
)
}
# theme_set(theme_grey()) # default
```
# Introduction
## Plot
- classic `ggplot2` example with custom SCL theme
```{r plot}
mpg %>%
ggplot (aes (x = displ, y = hwy)) +
geom_point (aes (color = class)) +
geom_smooth (color = scl_colors["logo" ]) +
paletteer:: scale_color_paletteer_d ("colorblindr::OkabeIto_black" ) +
theme_scl () +
labs (
title = "Plot Example" ,
subtitle = "Plot Subtitle" ,
x = "Engine displacement" ,
y = "Highway miles per gallon" ,
color = "Class" ,
caption = "Data: EPA, Graphic: socialchangelab.org"
)
```