Title: | UNHCR 'ggplot2' Theme and Colour Palettes |
---|---|
Description: | A 'ggplot2' theme and color palettes following the United Nations High Commissioner for Refugees (UNHCR) Data Visualization Guidelines recommendations. |
Authors: | Cédric Vidonne [aut, cre], Ahmadou Dicko [aut], UNHCR [cph] |
Maintainer: | Cédric Vidonne <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.6.2.9000 |
Built: | 2024-10-23 04:15:03 UTC |
Source: | https://github.com/unhcr-dataviz/unhcrthemes |
Displays a set of the color palettes from UNHCR color
display_unhcr_all(n = NULL, type = "all")
display_unhcr_all(n = NULL, type = "all")
n |
Number of different colors in the palette, minimum depending on the palette (2), maximum depending on the palette (5, 7 or 10) |
type |
Type of the palette, can be "sequential", "diverging", "qualitative" or "all" |
No return value, called for side effects
library(unhcrthemes) display_unhcr_all() display_unhcr_all(type = "diverging") display_unhcr_all(type = c("diverging", "qualitative", "sequential")) display_unhcr_all(n = 3, type = "sequential") display_unhcr_all(n = 5, type = "sequential")
library(unhcrthemes) display_unhcr_all() display_unhcr_all(type = "diverging") display_unhcr_all(type = c("diverging", "qualitative", "sequential")) display_unhcr_all(n = 3, type = "sequential") display_unhcr_all(n = 5, type = "sequential")
Displays a color palette from UNHCR brand color
display_unhcr_pal(n = NULL, name)
display_unhcr_pal(n = NULL, name)
n |
Number of different colors in the palette, minimum depending on palette (2), maximum depending on palette (5, 7 or 10) |
name |
A palette name |
No return value, called for side effects
display_unhcr_pal(3, "pal_unhcr")
display_unhcr_pal(3, "pal_unhcr")
Import Lato font for use in R graphic devices
import_lato()
import_lato()
No return value, called for side effects
Verify if you have Lato font installed in your system
lato_installed()
lato_installed()
TRUE if Lato is installed in the system
extrafont
Verify if Lato is registered through extrafont
lato_registered()
lato_registered()
TRUE if Lato is registered
UNHCR ggplot2 color scales
scale_color_unhcr_c( ..., type = "sequential", palette = 1, direction = 1, na.value = "#E9E9E9", guide = "colourbar" ) scale_color_unhcr_d( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9" ) scale_color_unhcr_b( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9", guide = "coloursteps" ) scale_colour_unhcr_c( ..., type = "sequential", palette = 1, direction = 1, na.value = "#E9E9E9", guide = "colourbar" ) scale_colour_unhcr_d( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9" ) scale_colour_unhcr_b( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9", guide = "coloursteps" ) scale_fill_unhcr_c( ..., type = "sequential", palette = 1, direction = 1, na.value = "#E9E9E9", guide = "colourbar" ) scale_fill_unhcr_d( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9" ) scale_fill_unhcr_b( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9", guide = "coloursteps" )
scale_color_unhcr_c( ..., type = "sequential", palette = 1, direction = 1, na.value = "#E9E9E9", guide = "colourbar" ) scale_color_unhcr_d( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9" ) scale_color_unhcr_b( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9", guide = "coloursteps" ) scale_colour_unhcr_c( ..., type = "sequential", palette = 1, direction = 1, na.value = "#E9E9E9", guide = "colourbar" ) scale_colour_unhcr_d( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9" ) scale_colour_unhcr_b( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9", guide = "coloursteps" ) scale_fill_unhcr_c( ..., type = "sequential", palette = 1, direction = 1, na.value = "#E9E9E9", guide = "colourbar" ) scale_fill_unhcr_d( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9" ) scale_fill_unhcr_b( ..., type = "qualitative", palette = 1, direction = 1, nmax = NULL, order = NULL, na.value = "#E9E9E9", guide = "coloursteps" )
... |
Other arguments passed on to |
type |
One of \"sequential\", \"diverging\" or \"qualitative\" |
palette |
If a string, will use that named palette. If a number, will
index into the list of palettes of appropriate |
direction |
Sets the order of colors in the scale. If 1, the default,
colors are as output by |
na.value |
Missing values will be replaced with this value. |
guide |
A function used to create a guide or its name. See
|
nmax |
Maximum number of different colors the palette should contain. If not provided, is calculated automatically from the data. |
order |
Numeric vector listing the order in which the colors should be used. Default is |
A discrete, continuous or binned Scale
object
library(ggplot2) data(msleep, package = "ggplot2") ggplot(msleep, aes(vore, sleep_total, fill = vore)) + geom_boxplot() + scale_fill_unhcr_d(palette = 1, direction = -1)
library(ggplot2) data(msleep, package = "ggplot2") ggplot(msleep, aes(vore, sleep_total, fill = vore)) + geom_boxplot() + scale_fill_unhcr_d(palette = 1, direction = -1)
theme_unhcr
provides a basic UNHCR theme
to use in ggplot2 commands.
theme_unhcr( font_family = if (lato_installed()) "Lato" else "sans", font_size = 12, plot_title_size = rel(1.35), plot_title_margin = font_size, subtitle_size = font_size, subtitle_margin = font_size * 1.5, strip_text_size = rel(0.9), strip_text_face = "bold", strip_text_just = 0, caption_size = rel(0.7), caption_margin = font_size, axis_text = TRUE, axis_text_size = rel(0.9), axis_title = TRUE, axis_title_size = rel(0.9), axis = FALSE, axis_ticks = FALSE, grid = "XY", legend = TRUE, legend_text_size = rel(0.9), legend_title = FALSE, legend_title_size = rel(0.9), plot_margin = margin(font_size, font_size, font_size, font_size), plot_background = "#ffffff", void = FALSE )
theme_unhcr( font_family = if (lato_installed()) "Lato" else "sans", font_size = 12, plot_title_size = rel(1.35), plot_title_margin = font_size, subtitle_size = font_size, subtitle_margin = font_size * 1.5, strip_text_size = rel(0.9), strip_text_face = "bold", strip_text_just = 0, caption_size = rel(0.7), caption_margin = font_size, axis_text = TRUE, axis_text_size = rel(0.9), axis_title = TRUE, axis_title_size = rel(0.9), axis = FALSE, axis_ticks = FALSE, grid = "XY", legend = TRUE, legend_text_size = rel(0.9), legend_title = FALSE, legend_title_size = rel(0.9), plot_margin = margin(font_size, font_size, font_size, font_size), plot_background = "#ffffff", void = FALSE )
font_family |
Base font family "Lato". You need to have "Lato" font installed on your device in order to use it. |
font_size |
Base font size in pt. Default to 12 pts. |
plot_title_size |
Plot title font size. Default to |
plot_title_margin |
Plot title bottom margin. Default to |
subtitle_size |
Plot subtitle font size. Default to |
subtitle_margin |
Plot subtitle bottom margin. Default to |
strip_text_size |
Facet label font size. Default to |
strip_text_face |
Facet label font face. Default to "bold". |
strip_text_just |
Facet label justification. Default to 0. |
caption_size |
Caption font size. Default to |
caption_margin |
Caption top margin. Default to |
axis_text |
Logical |
axis_text_size |
Axis label font size. Default to |
axis_title |
Logical |
axis_title_size |
Axis title font size. Default to |
axis |
Logical |
axis_ticks |
Logical |
grid |
Logical |
legend |
Logical |
legend_text_size |
Legend key font size. Default to |
legend_title |
Logical |
legend_title_size |
Legend title font size. Default to |
plot_margin |
Plot margin (specify with |
plot_background |
Plot background. Put "transparent" for no background color. Default to "white". |
void |
Logical |
A ggplot2 theme object, the theme style.
## Not run: library(ggplot2) data(mpg, package = "ggplot2") ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_unhcr() ## End(Not run)
## Not run: library(ggplot2) data(mpg, package = "ggplot2") ggplot(mpg, aes(displ, hwy)) + geom_point() + theme_unhcr() ## End(Not run)
Creates a color palette from UNHCR branding
unhcr_pal(n = NULL, name, ...)
unhcr_pal(n = NULL, name, ...)
n |
Number of different colors in the palette, minimum depending on palette (2), maximum depending on palette (5, 7 or 10) |
name |
A palette name |
... |
Additional arguments for grDevices::colorRampPalette |
A character vector, the palette hex color codes.
unhcr_pal(3, "pal_unhcr") unhcr_pal(3, "pal_blue") unhcr_pal(5, "pal_navy") unhcr_pal(12, "pal_red")
unhcr_pal(3, "pal_unhcr") unhcr_pal(3, "pal_blue") unhcr_pal(5, "pal_navy") unhcr_pal(12, "pal_red")