Skip to content

Commit

Permalink
all data-driving graphics use roboto text
Browse files Browse the repository at this point in the history
  • Loading branch information
fawda123 committed May 13, 2024
1 parent b7f06bc commit 4c73e37
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ jobs:
any::rmarkdown
any::knitr
any::prettymapr
any::sysfonts
any::showtext
- name: Publish to GitHub Pages (and render)
uses: quarto-dev/quarto-actions/publish@v2
Expand Down
75 changes: 48 additions & 27 deletions R/funcs.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

sysfonts::font_add_google('Roboto')
showtext::showtext_auto()
showtext::showtext_opts(dpi = 200)

# utility functions ---------------------------------------------------------------------------

# get rdata from github
Expand Down Expand Up @@ -67,14 +71,15 @@ pyro_plo <- function(yr = 2021, mo = c('Jun', 'Oct')){

m <- m +
ggplot2::geom_sf(data = tomap, ggplot2::aes(size = count), fill = 'red', color = 'red', pch = 21, alpha = 0.5, inherit.aes = F) +
ggplot2::theme_minimal() +
ggplot2::theme_minimal(base_family = 'Roboto') +
ggplot2::theme(
panel.grid = ggplot2::element_blank(),
axis.title = ggplot2::element_blank(),
axis.text.y = ggplot2::element_text(size = 8),
axis.text.x = ggplot2::element_text(size = 8, angle = 30, hjust = 1),
axis.ticks = ggplot2::element_line(colour = 'grey'),
panel.background = ggplot2::element_rect(fill = NA, color = 'black')
panel.background = ggplot2::element_rect(fill = NA, color = 'black'),
text = ggplot2::element_text(family = 'Roboto')
) +
ggplot2::scale_size_continuous(range = c(2, 10)) +
ggplot2::labs(
Expand All @@ -84,7 +89,7 @@ pyro_plo <- function(yr = 2021, mo = c('Jun', 'Oct')){
)

m <- m +
ggspatial::annotation_scale(location = 'br', unit_category = 'metric')
ggspatial::annotation_scale(location = 'br', unit_category = 'metric', text_family = 'Roboto')
m <- m +
ggspatial::annotation_north_arrow(location = 'tl', which_north = "true", height = grid::unit(0.75, "cm"),
width = grid::unit(0.75, "cm"))
Expand Down Expand Up @@ -129,10 +134,11 @@ adload_plo <- function(){
ggplot2::geom_text(ggplot2::aes(label = percent, size = toemph), hjust = -0.25, show.legend = F) +
ggplot2::scale_fill_manual(values = c('#004F7E', '#958984')) +
ggplot2::scale_x_continuous(expand = c(0, 0), limits = c(0, 1.1* max(toplo$tn_load / 1000))) +
ggplot2::theme_minimal(base_size = 14) +
ggplot2::theme_minimal(base_size = 14, base_family = 'Roboto') +
ggplot2::scale_y_discrete(expand = c(0, 0)) +
ggplot2::theme(
panel.grid = ggplot2::element_blank(),
text = ggplot2::element_text(family = 'Roboto')
# axis.text = ggplot2::element_text(size = 14)
) +
ggplot2::scale_size_manual(values = c(6, 4)) +
Expand Down Expand Up @@ -167,12 +173,13 @@ bacwbid_plo <- function(){
dplyr::select(-PARAMETER_GROUP, -PARAMETER_ASSESSED) |>
unique()

m <- ggplot() +
m <- ggplot2::ggplot() +
annotation_map_tile(zoom = 10, type = 'cartolight', progress = 'none', quiet = T) +
ggspatial::annotation_scale(location = 'br', unit_category = 'metric') +
ggspatial::annotation_scale(location = 'br', unit_category = 'metric', text_family = 'Roboto') +
ggspatial::annotation_north_arrow(location = 'tl', which_north = "true", height = grid::unit(0.75, "cm"), width = grid::unit(0.75, "cm")) +
geom_sf(data = tbvwbid, fill = 'red', col = 'red', alpha = 0.6) +
theme_minimal()
ggplot2::geom_sf(data = tbvwbid, fill = 'red', col = 'red', alpha = 0.6) +
ggplot2::theme_minimal(base_family = 'Roboto') +
ggplot2::theme(text = ggplot2::element_text(family = 'Roboto'))

return(m)

Expand Down Expand Up @@ -214,10 +221,11 @@ intertidal_plo <- function(curyr = 2020){
color = 'white', fontface = 'bold') +
ggplot2::facet_wrap(~name) +
ggplot2::coord_polar('y', start = 0) +
ggplot2::theme_void() +
ggplot2::theme_void(base_family = 'Roboto') +
ggplot2::scale_fill_manual(values = c('#028576', '#427355', '#76923C')) +
ggplot2::theme(
legend.position = 'bottom',
text = ggplot2::element_text(family = 'Roboto'),
strip.text = ggplot2::element_text(size = 15),
legend.text = ggplot2::element_text(size = 13)
) +
Expand Down Expand Up @@ -249,15 +257,18 @@ cchasites_plo <- function(){

m <- ggplot2::ggplot() +
ggspatial::annotation_map_tile(zoom = 10, type = 'cartolight', quiet = T, progress = 'none') +
ggspatial::annotation_scale(location = 'bl', unit_category = 'metric') +
ggspatial::annotation_scale(location = 'bl', unit_category = 'metric', text_family = 'Roboto') +
ggspatial::annotation_north_arrow(location = 'tr', which_north = "true", height = grid::unit(0.75, "cm"), width = grid::unit(0.75, "cm")) +
ggplot2::geom_sf(data = tomap, inherit.aes = F, size = 2) +
ggrepel::geom_text_repel(data = tomap, ggplot2::aes(label = site, x = lon, y = lat), inherit.aes = F) +
ggplot2::labs(
x = NULL,
y = NULL
) +
ggplot2::theme_minimal() +
ggplot2::theme_minimal(base_family = 'Roboto') +
ggplot2::theme(
text = ggplot2::element_text(family = 'Roboto')
) +
ggplot2::coord_sf(xlim = dat_ext[c(1, 3)], ylim = dat_ext[c(2, 4)], expand = FALSE, crs = 4326)

return(m)
Expand Down Expand Up @@ -288,7 +299,7 @@ tdlcrk_plo <- function(maxyr = 2022){

m <- ggplot2::ggplot() +
ggspatial::annotation_map_tile(zoom = 10, type = 'cartolight', quiet = T, progress = 'none') +
ggspatial::annotation_scale(location = 'bl', unit_category = 'metric') +
ggspatial::annotation_scale(location = 'bl', unit_category = 'metric', text_family = 'Roboto') +
ggspatial::annotation_north_arrow(location = 'tr', which_north = "true", height = grid::unit(0.75, "cm"), width = grid::unit(0.75, "cm")) +
ggplot2::geom_sf(data = tomap, ggplot2::aes(col = score, fill = score), inherit.aes = F, linewidth = 0.75) +
ggplot2::scale_color_manual(values = cols) +
Expand All @@ -299,7 +310,10 @@ tdlcrk_plo <- function(maxyr = 2022){
color = NULL,
fill = NULL
) +
ggplot2::theme_minimal() +
ggplot2::theme_minimal(base_family = 'Roboto') +
ggplot2::theme(
text = ggplot2::element_text(family = 'Roboto')
) +
ggplot2::coord_sf(xlim = dat_ext[c(1, 3)], ylim = dat_ext[c(2, 4)], expand = FALSE, crs = 4326)

return(m)
Expand Down Expand Up @@ -343,12 +357,13 @@ scallop_plo <- function(){
x = NULL,
y = 'Scallops found'
) +
ggplot2::theme_minimal() +
ggplot2::theme_minimal(base_family = 'Roboto') +
ggplot2::theme(
axis.text.x = ggplot2::element_text(angle = 45, hjust = 1),
panel.grid.major.x = ggplot2::element_blank(),
panel.grid.minor.x = ggplot2::element_blank(),
panel.grid.minor.y = ggplot2::element_blank()
panel.grid.minor.y = ggplot2::element_blank(),
text = ggplot2::element_text(family = 'Roboto')
)

return(p)
Expand Down Expand Up @@ -389,15 +404,16 @@ fim_plo <- function(){
x = NULL,
y = 'Number per set'
) +
ggplot2::theme_minimal() +
ggplot2::theme_minimal(base_family = 'Roboto') +
ggplot2::theme(
legend.position = 'none',
panel.grid.minor.y = ggplot2::element_blank(),
strip.text = ggplot2::element_text(size = 12),
# panel.grid.major.x = ggplot2::element_blank(),
panel.grid.minor.x = ggplot2::element_blank(),
axis.title.y = ggplot2::element_text(size = 12),
axis.text.x = ggplot2::element_text(size = 11)
axis.text.x = ggplot2::element_text(size = 11),
text = ggplot2::element_text(family = 'Roboto')
)

return(p)
Expand All @@ -423,7 +439,7 @@ waterbird_plo <- function(){

m <- ggplot2::ggplot() +
ggspatial::annotation_map_tile(zoom = 10, type = 'cartolight', quiet = T, progress = 'none') +
ggspatial::annotation_scale(location = 'br', unit_category = 'metric') +
ggspatial::annotation_scale(location = 'br', unit_category = 'metric', text_family = 'Roboto') +
ggspatial::annotation_north_arrow(location = 'tl', which_north = "true", height = grid::unit(0.75, "cm"), width = grid::unit(0.75, "cm")) +
ggplot2::geom_sf(data = tomap, ggplot2::aes(fill = status), col = 'black', pch = 21, inherit.aes = F, size = 3) +
# ggplot2::scale_color_manual(values = cols) +
Expand All @@ -434,9 +450,10 @@ waterbird_plo <- function(){
color = NULL,
fill = NULL
) +
ggplot2::theme_minimal() +
ggplot2::theme_minimal(base_family = 'Roboto') +
ggplot2::theme(
legend.position = 'top'
legend.position = 'top',
text = ggplot2::element_text(family = 'Roboto')
)

return(m)
Expand Down Expand Up @@ -496,21 +513,24 @@ gadsum_plo <- function(h = 5.5, w = 30, padding = 0, rows = 5){
dplyr::mutate(
x = rep(seq(0, (!!w + padding) * cols - 1, !!w + padding), times = rows),
y = rep(seq(0, (!!h + padding) * rows - 1, !!h + padding), each = cols),
info = stringr::str_wrap(info, 75)
info = stringr::str_wrap(info, 80)
)

p <- ggplot2::ggplot(toplo, ggplot2::aes(x, y, height = h, width = w, label = info)) +
ggplot2::geom_tile(ggplot2::aes(fill = name)) +
ggplot2::geom_text(fontface = "bold", size = 12,
ggplot2::geom_text(fontface = "bold", size = 6,
ggplot2::aes(label = value, x = x - w/2.2, y = y + h/4, color = name), hjust = 0) +
ggplot2::geom_text(size = 7, lineheight = 0.5,
ggplot2::geom_text(size = 3.3, lineheight = 1.2,
ggplot2::aes(color = name, label = info, x = x - w/2.2, y = y - h/6), hjust = 0) +
ggplot2::coord_fixed() +
ggplot2::scale_fill_brewer(type = "cont", palette = "Blues", direction = -1) +
ggplot2::scale_color_manual(values = toplo$txtcols) +
ggplot2::geom_text(size = 32, ggplot2::aes(label = icon, family = font_family,
ggplot2::geom_text(size = 17, ggplot2::aes(label = icon, family = font_family,
x = x + w/2.5, y = y + h/14), alpha = 0.25) +
ggplot2::theme_void() +
ggplot2::theme_void(base_family = 'Roboto') +
ggplot2::theme(
text = ggplot2::element_text(family = 'Roboto')
) +
ggplot2::guides(
fill = 'none',
color = 'none'
Expand Down Expand Up @@ -566,12 +586,13 @@ seagrassph_plo <- function(){
x = NULL,
fill = NULL
) +
ggplot2::theme_minimal() +
ggplot2::theme_minimal(base_family = 'Roboto') +
ggplot2::theme(
legend.position = 'top',
panel.grid.minor = ggplot2::element_blank(),
axis.text.x = ggplot2::element_text(size = 11),
legend.text = ggplot2::element_text(size = 11)
legend.text = ggplot2::element_text(size = 11),
text = ggplot2::element_text(family = 'Roboto')
)

return(p)
Expand Down
4 changes: 2 additions & 2 deletions _site/docs/communities/cc1.html

Large diffs are not rendered by default.

Loading

0 comments on commit 4c73e37

Please sign in to comment.