Skip to content

Commit

Permalink
Merge pull request #79 from katilingban/dev
Browse files Browse the repository at this point in the history
edit vignettes; set Roboto Condensed as default paleta font
  • Loading branch information
ernestguevarra authored Mar 16, 2024
2 parents 8eb64af + 639cba2 commit 4b34677
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 46 deletions.
14 changes: 7 additions & 7 deletions R/theme_nhs.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,14 @@ theme_nhs <- function(base_family = set_nhs_font(),
plot_title_family = base_family,
plot_title_colour = nhs_blue,
subtitle_family = base_family,
subtitle_colour = nhs_mid_grey,
caption_colour = nhs_mid_grey,
axis_title_colour = nhs_mid_grey,
legend_title_colour = nhs_mid_grey,
legend_text_colour = nhs_mid_grey,
grid_col = nhs_pale_grey,
subtitle_colour = nhs_dark_grey,
caption_colour = nhs_dark_grey,
axis_title_colour = nhs_dark_grey,
legend_title_colour = nhs_dark_grey,
legend_text_colour = nhs_dark_grey,
grid_col = nhs_mid_grey,
grid = TRUE,
axis_col = nhs_pale_grey,
axis_col = nhs_mid_grey,
axis = FALSE,
ticks = FALSE) {
theme_paleta(
Expand Down
27 changes: 14 additions & 13 deletions R/theme_paleta.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
paleta_fonts <- list(
paleta_noto = "Noto Sans",
paleta_roboto = "Roboto",
paleta_arial_narrow = "Arial Narrow"
paleta_roboto_condensed = "Roboto Condensed"
)

#'
#' Set paleta font based on what is available in the system
#'
#' The function will search the system for availability of any of the paleta
#' fonts in heirarchical order starting with *Arial Narrow*, then *Noto Sans*,
#' and then *Roboto*.
#' fonts in heirarchical order starting with *Roboto Condensed*, then
#' *Noto Sans*, and then *Roboto*.
#'
#' @return A character value for font family to use as paleta font.
#'
Expand All @@ -34,8 +34,8 @@ set_paleta_font <- function() {
fonts <- systemfonts::system_fonts()

## Check which paleta font is available ----
if (any(fonts$family == paleta_fonts$paleta_arial_narrow)) {
paleta_font <- paleta_fonts$paleta_arial_narrow
if (any(fonts$family == paleta_fonts$paleta_roboto_condensed)) {
paleta_font <- paleta_fonts$paleta_roboto_condensed
} else {
if (any(fonts$family == paleta_fonts$paleta_noto)) {
paleta_font <- paleta_fonts$paleta_noto
Expand All @@ -58,13 +58,12 @@ set_paleta_font <- function() {
#' drawing heavily on its typography-centric focus.
#'
#' @details
#' This function uses either of three fonts - *Arial Narrow*, *Noto Sans*, or
#' *Roboto* (in this specific order) - depending on what is available in the
#' user's system. *Arial Narrow* is generally installed by default or readily
#' available on any modern system. If it is not available, then *Noto Sans* or
#' *Roboto* - both Google fonts - are freely downloadable and easily installed
#' on any system. If *Arial Narrow* is not available in your system, download
#' and install either/both *Noto Sans* and/or *Roboto* from
#' This function uses either of three fonts - *Roboto Condensed*, *Noto Sans*,
#' or *Roboto* (in this specific order) - depending on what is available in the
#' user's system. *Roboto Condensed*, *Noto Sans*, and *Roboto* - all Google
#' fonts - are freely downloadable and easily installed on any system.
#' If any of these fonts is not available in your system, download and install
#' either/all *Roboto Condensed*, *Noto Sans* and/or *Roboto* from
#' [Google Fonts](https://fonts.google.com/).
#'
#' @param base_family Base font family using Africa CDC fonts. Default is set
Expand Down Expand Up @@ -181,7 +180,9 @@ theme_paleta <- function(base_family = set_paleta_font(),
} else {
design <- design +
ggplot2::theme(
plot.background = ggplot2::element_rect(fill = plot_background_fill)
plot.background = ggplot2::element_rect(
fill = plot_background_fill, colour = plot_background_fill
)
)
}

Expand Down
4 changes: 2 additions & 2 deletions man/paleta_font.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions man/theme_nhs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions man/theme_paleta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vignettes/africa-cdc.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ ggplot(
subtitle = "Using the Africa CDC secondary palette",
x = "Engine Shape", y = "Counts"
) +
theme_acdc_light()
theme_acdc_light(grid = "Y")
```

```{r mtcars-acdc-light-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
Expand All @@ -142,7 +142,7 @@ ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
title = "Light ACDC Theme",
subtitle = "Using the Africa CDC secondary palette",
) +
theme_acdc_light()
theme_acdc_light(grid = "XY")
```


Expand All @@ -163,7 +163,7 @@ ggplot(
subtitle = "Using the Africa CDC secondary palette",
x = "Engine Shape", y = "Counts"
) +
theme_acdc_dark()
theme_acdc_dark(grid = "Y")
```

```{r mtcars-acdc-dark-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
Expand All @@ -178,5 +178,5 @@ ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
title = "Dark ACDC Theme",
subtitle = "Using the Africa CDC secondary palette"
) +
theme_acdc_dark()
theme_acdc_dark(grid = "XY")
```
4 changes: 2 additions & 2 deletions vignettes/nhs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ggplot(
subtitle = "NHS blue tints palette",
x = "Engine Shape", y = "Counts"
) +
theme_nhs(base_size = 10)
theme_nhs(grid = "Y")
```

```{r nhs-theme-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
Expand All @@ -104,5 +104,5 @@ ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
title = "NHS Theme",
subtitle = "NHS support greens palette",
) +
theme_nhs(base_size = 10)
theme_nhs(grid = "XY")
```
4 changes: 2 additions & 2 deletions vignettes/unicef.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ggplot(
subtitle = "UNICEF brights palette",
x = "Engine Shape", y = "Counts"
) +
theme_unicef()
theme_unicef(grid = "Y")
```

```{r unicef-theme-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
Expand All @@ -82,6 +82,6 @@ ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
title = "UNICEF Theme",
subtitle = "UNICEF brights palette",
) +
theme_unicef()
theme_unicef(grid = "XY")
```

4 changes: 2 additions & 2 deletions vignettes/world-bank.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ ggplot(
subtitle = "World Bank neutral palette (tinted to 40%)",
x = "Engine Shape", y = "Counts"
) +
theme_wb()
theme_wb(grid = "Y")
```

```{r wb-theme-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
Expand All @@ -182,5 +182,5 @@ ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
title = "World Bank Theme",
subtitle = "World Bank neutral palette (tinted to 40%)",
) +
theme_wb()
theme_wb(grid = "XY")
```

0 comments on commit 4b34677

Please sign in to comment.