Skip to content

Commit 9b109d8

Browse files
committed
More vignette
1 parent 2419d11 commit 9b109d8

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

vignettes/wbplot.Rmd

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: "Using the wbplot ggplot2 theme"
2+
title: "wbplot: the World Bank ggplot2 theme"
33
output: rmarkdown::html_vignette
44
vignette: >
5-
%\VignetteIndexEntry{Using the wbplot ggplot2 theme}
5+
%\VignetteIndexEntry{wbplot: the World Bank ggplot2 theme}
66
%\VignetteEngine{knitr::rmarkdown}
77
%\VignetteEncoding{UTF-8}
88
---
@@ -22,6 +22,10 @@ knitr::opts_chunk$set(
2222
)
2323
```
2424

25+
## What is wbplot?
26+
27+
wbplot is an R package that provides functions for theming ggplot2 visualizations according to the [World Bank Data Visualization Style Guide](https://wbg-vis-design.vercel.app/).
28+
2529
## Installation and loading
2630

2731
Install the package with `devtools::install_github("worldbank/wbplot")` or `remotes::install_github("worldbank/wbplot")`.
@@ -275,6 +279,33 @@ beeswarm +
275279

276280
## Colors
277281

282+
All colors of the World Bank Data Visualization Style Guide are available through `WBCOLORS`.
283+
284+
```{r}
285+
WBCOLORS$female
286+
287+
WBCOLORS$noData
288+
```
289+
290+
Likewise, all color palettes are available through `WBPALETTES`.
291+
292+
The sequential palettes are `WBPALETTES$seq`, `WBPALETTES$seqRev`, `WBPALETTES$seqB`
293+
, `WBPALETTES$seqY` and `WBPALETTES$seqP`. The diverging palettes are `WBPALETTES$divPosNeg` and `WBPALETTES$divLR`. All these palettes can be used with the continuous and binned color scales (`scale_fill_wb_c()`, `scale_color_wb_c()`, `scale_fill_wb_b()`, `scale_color_wb_b()`), with the palette parameter (eg. `scale_fill_wb_c(palette = "seqY")`).
278294

295+
The discrete color palettes are `default`, `defaultText`, `region`, `regionText`, `income`, `gender`, `urbanisation`, `age` and `binary`. These can be used in `scale_fill_wb_d()` and `scale_color_wb_d()`, with the `palette` parameter. When the values in the mapped column correspond to the names of the colors of the palette, values are automatically matched to the correct color.
296+
297+
```{r}
298+
WBPALETTES$income
299+
300+
WBPALETTES$gender
301+
```
279302

280303
## Saving plots
304+
305+
As always , you can save plots with `ggsave()`. You should be able to get good results by setting `units` to "px", `width` to 960, and `scale` to 2. The optimal `height` is determined by the chart type and the data, but the default is 540.
306+
307+
```{r, eval = FALSE}
308+
ggsave(filename = "my-worldbank-chart.png", units = "px", width = 960, height = 540, scale = 2)
309+
```
310+
311+
For convenience, you can use `ggsave_wb(filename = "my-worldbank-chart.png")`, which has these values for units, dimensions and scale by default.

0 commit comments

Comments
 (0)