You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vignettes/wbplot.Rmd
+33-2
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
---
2
-
title: "Using the wbplot ggplot2 theme"
2
+
title: "wbplot: the World Bank ggplot2 theme"
3
3
output: rmarkdown::html_vignette
4
4
vignette: >
5
-
%\VignetteIndexEntry{Using the wbplot ggplot2 theme}
5
+
%\VignetteIndexEntry{wbplot: the World Bank ggplot2 theme}
6
6
%\VignetteEngine{knitr::rmarkdown}
7
7
%\VignetteEncoding{UTF-8}
8
8
---
@@ -22,6 +22,10 @@ knitr::opts_chunk$set(
22
22
)
23
23
```
24
24
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
+
25
29
## Installation and loading
26
30
27
31
Install the package with `devtools::install_github("worldbank/wbplot")` or `remotes::install_github("worldbank/wbplot")`.
@@ -275,6 +279,33 @@ beeswarm +
275
279
276
280
## Colors
277
281
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")`).
278
294
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
+
```
279
302
280
303
## 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.
0 commit comments