Site defaults
_defaults.R
library(ggplot2)
library(ggdist)
library(showtext)
library(patchwork)
library(rlang)
library(systemfonts)
font_add_google("Public Sans", "Public Sans")
font_add_google("Fira Code", "Fira Code")
# font_add(
# family = "Public Sans",
# regular = here::here("assets", "Public_Sans", "static", "PublicSans-Regular.ttf"),
# italic = here::here("assets", "Public_Sans", "static", "PublicSans-Italic.ttf"),
# bold = here::here("assets", "Public_Sans", "static", "PublicSans-Bold.ttf")
# )
showtext_auto()
= "#CC6677"
ptol_red = "#4477AA"
ptol_blue
theme_set(
theme_ggdist(base_size = 12) +
theme(
text = element_text(
family = "Public Sans",
#face = "regular"
)
)
)
<- function(){
dark_theme theme(
panel.border = element_blank(),
text = element_text(colour = "white"),
axis.text = element_text(colour = "white"),
rect = element_rect(colour = "#222", fill = "#222"),
plot.background = element_rect(fill = "#222", colour = NA),
panel.background = element_rect(fill = "#424952"),
strip.background = element_rect(fill="#3d3d3d"),
strip.text = element_text(color = "white")
#axis.line = element_line(colour = "white"),
#axis.ticks = element_line(colour = "white")
)
}
<- "#4477AA"
tol_blue
<- function(){
theme_no_y theme(
axis.text.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.y = element_blank()
)
}
# ragg_png <- ragg_png <- function(..., res = 150) {
# ragg::agg_png(..., res = res, units = "in")
# }
<- function(file, width, height){
light_png ggsave(
filename = file,
width = width,
height = height,
dev = png
)
}
<- function(file, width, height) {
dark_png on.exit(ggdark::invert_geom_defaults())
::invert_geom_defaults()
ggdark<- last_plot()
p if("patchwork" %in% class(p)){
<- p & dark_theme()
p else{
}<- p + dark_theme()
p
}ggsave(
filename = file,
plot = p,
width = width,
height = height,
dev = png
)
}
::knit_hooks$set(crop = knitr::hook_pdfcrop)
knitr
options(
mc.cores = parallel::detectCores(),
ggplot2.discrete.colour = lapply(1:12, ggthemes::ptol_pal()),
ggplot2.discrete.fill = lapply(1:12, ggthemes::ptol_pal()),
ggplot2.continuous.colour = \(x) scico::scale_color_scico(palette = "batlow"),
ggplot2.continuous.fill = \(x) scico::scale_fill_scico(palette = "batlow")
)
<- function(tbl){
my_gt_theme
<- list(
style_cells cells_body(),
cells_column_labels(),
cells_column_spanners(),
cells_footnotes(),
cells_group(),
cells_row_groups(),
cells_source_notes(),
cells_stub(),
cells_stubhead(),
cells_title()
)
<- tbl$`_summary` |>
summary_info map(
~":GRAND_SUMMARY:" %in% .x$groups
|>
) list_simplify()
if(any(summary_info)){
<- c(
style_cells
style_cells,list(
cells_grand_summary(),
cells_stub_grand_summary()
)
)
}
if(any(!(summary_info %||% T))){
<- c(
style_cells
style_cells,list(
cells_stub_summary(),
cells_summary()
)
)
}
|>
tbl opt_table_font(
font = c(
google_font(name = "Public Sans"),
default_fonts()
)|>
)tab_style(
style = "
background-color: var(--bs-body-bg);
color: var(--bs-body-color)
",
locations = style_cells
)
}
Reuse
CC-BY 4.0
Citation
BibTeX citation:
@online{fruehwald,
author = {Fruehwald, Josef},
title = {Site Defaults},
url = {https://lin611-2024.github.io/default.html},
langid = {en}
}
For attribution, please cite this work as:
Fruehwald, Josef. n.d. “Site Defaults.” https://lin611-2024.github.io/default.html.