Skip to content

Commit

Permalink
Merge pull request #80 from katilingban/dev
Browse files Browse the repository at this point in the history
use showtext and sysfonts to show fonts properly in Rmds
  • Loading branch information
ernestguevarra authored Mar 29, 2024
2 parents 4b34677 + 210ee72 commit feb0088
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ Imports:
withr
Suggests:
knitr,
ragg,
rmarkdown,
showtext,
spelling,
sysfonts,
testthat (>= 3.0.0)
Encoding: UTF-8
Language: en-GB
Expand Down
13 changes: 8 additions & 5 deletions vignettes/africa-cdc.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ vignette: >

```{r, include = FALSE}
knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
collapse = TRUE,
comment = "#>"
comment = "#>",
dev = "ragg_png"
)
```

Expand Down Expand Up @@ -112,7 +115,7 @@ structure(acdc_palettes$acdc_dark_greens, class = "palette", name = "Africa CDC

### Africa CDC light theme

```{r mtcars-acdc-light-bar, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
```{r mtcars-acdc-light-bar, echo = FALSE, fig.align = "center", fig.showtext = TRUE, fig.height = 6, fig.width = 5, fig.retina = 1}
## barplot using theme_acdc_light
ggplot(
data = mtcars,
Expand All @@ -130,7 +133,7 @@ ggplot(
theme_acdc_light(grid = "Y")
```

```{r mtcars-acdc-light-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
```{r mtcars-acdc-light-scatter, echo = FALSE, fig.align = "center", fig.showtext = TRUE, fig.height = 6, fig.width = 5, fig.retina = 1}
## scatterplot using theme_acdc_light
ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
geom_point(size = 3) +
Expand All @@ -148,7 +151,7 @@ ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +

### Africa CDC dark theme

```{r mtcars-acdc-dark-bar, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
```{r mtcars-acdc-dark-bar, echo = FALSE, fig.align = "center", fig.showtext = TRUE, fig.height = 6, fig.width = 5, fig.retina = 1}
## barplot using theme_acdc_dark
ggplot(
data = mtcars,
Expand All @@ -166,7 +169,7 @@ ggplot(
theme_acdc_dark(grid = "Y")
```

```{r mtcars-acdc-dark-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
```{r mtcars-acdc-dark-scatter, echo = FALSE, fig.align = "center", fig.showtext = TRUE, fig.height = 6, fig.width = 5, fig.retina = 1}
## scatterplot using theme_acdc_dark
ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
geom_point(size = 3) +
Expand Down
9 changes: 6 additions & 3 deletions vignettes/nhs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ vignette: >

```{r, include = FALSE}
knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
collapse = TRUE,
comment = "#>"
comment = "#>",
dev = "ragg_png"
)
```

Expand Down Expand Up @@ -71,7 +74,7 @@ structure(nhs_palettes$nhs_highlights, class = "palette", name = "NHS Highlights

An NHS `ggplot2` theme function called `theme_nhs()` is included in the `paleta` package. Following are examples of how it can be used.

```{r nhs-theme-bar, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
```{r nhs-theme-bar, echo = FALSE, fig.align = "center", fig.showtext = TRUE, fig.height = 6, fig.width = 5, fig.retina = 1}
## barplot using theme_nhs()
ggplot(
data = mtcars,
Expand All @@ -92,7 +95,7 @@ ggplot(
theme_nhs(grid = "Y")
```

```{r nhs-theme-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
```{r nhs-theme-scatter, echo = FALSE, fig.align = "center", fig.showtext = TRUE, fig.height = 6, fig.width = 5, fig.retina = 1}
## scatterplot using theme_nhs()
ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
geom_point(size = 3) +
Expand Down
5 changes: 4 additions & 1 deletion vignettes/paleta.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ vignette: >

```{r, include = FALSE}
knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
collapse = TRUE,
comment = "#>"
comment = "#>",
dev = "ragg_png"
)
```

Expand Down
9 changes: 6 additions & 3 deletions vignettes/unicef.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ vignette: >

```{r, include = FALSE}
knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
collapse = TRUE,
comment = "#>"
comment = "#>",
dev = "ragg_png"
)
```

Expand Down Expand Up @@ -49,7 +52,7 @@ structure(unicef_palettes$unicef_neutrals, class = "palette", name = "UNICEF Neu

A UNICEF `ggplot2` theme function called `theme_unicef()` is included in the `paleta` package. Following are examples of how it can be used.

```{r unicef-theme-bar, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
```{r unicef-theme-bar, echo = FALSE, fig.align = "center", fig.showtext = TRUE, fig.height = 6, fig.width = 5, fig.retina = 1}
## barplot using theme_unicef()
ggplot(
data = mtcars,
Expand All @@ -70,7 +73,7 @@ ggplot(
theme_unicef(grid = "Y")
```

```{r unicef-theme-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
```{r unicef-theme-scatter, echo = FALSE, fig.align = "center", fig.showtext = TRUE, fig.height = 6, fig.width = 5, fig.retina = 1}
## scatterplot using theme_unicef()
ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
geom_point(size = 3) +
Expand Down
9 changes: 6 additions & 3 deletions vignettes/world-bank.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ vignette: >

```{r, include = FALSE}
knitr::opts_chunk$set(
message = FALSE,
warning = FALSE,
collapse = TRUE,
comment = "#>"
comment = "#>",
dev = "ragg_png"
)
```

Expand Down Expand Up @@ -149,7 +152,7 @@ structure(wb_palettes$wb_dark_greens, class = "palette", name = "World Bank Dark

A World Bank `ggplot2` theme function called `theme_wb()` is included in the `paleta` package. Following are examples of how it can be used.

```{r wb-theme-bar, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
```{r wb-theme-bar, echo = FALSE, fig.align = "center", fig.showtext = TRUE, fig.height = 6, fig.width = 5, fig.retina = 1}
## barplot using theme_wb()
ggplot(
data = mtcars,
Expand All @@ -170,7 +173,7 @@ ggplot(
theme_wb(grid = "Y")
```

```{r wb-theme-scatter, echo = FALSE, fig.align = "center", fig.height = 6, fig.width = 5}
```{r wb-theme-scatter, echo = FALSE, fig.align = "center", fig.showtext = TRUE, fig.height = 6, fig.width = 5, fig.retina = 1}
## scatterplot using theme_wb()
ggplot(data = mtcars, mapping = aes(x = mpg, y = disp, colour = factor(cyl))) +
geom_point(size = 3) +
Expand Down

0 comments on commit feb0088

Please sign in to comment.