unhcrthemes
UNHCR branded theme for ggplot2 and data visualization colour palettes
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (18.7%) to scientific vocabulary
Keywords
ggplot2
ggplot2-scales
ggplot2-themes
Last synced: 6 months ago
·
JSON representation
Repository
UNHCR branded theme for ggplot2 and data visualization colour palettes
Basic Info
- Host: GitHub
- Owner: unhcr-dataviz
- License: other
- Language: R
- Default Branch: master
- Homepage: https://unhcr-dataviz.github.io/unhcrthemes/
- Size: 49.2 MB
Statistics
- Stars: 30
- Watchers: 2
- Forks: 7
- Open Issues: 3
- Releases: 5
Topics
ggplot2
ggplot2-scales
ggplot2-themes
Created about 5 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
License
Code of conduct
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.retina = 2,
dpi = 300,
dev = "ragg_png"
)
```
# unhcrthemes
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://github.com/unhcr-dataviz/unhcrthemes/actions/workflows/R-CMD-check.yaml)
[](https://CRAN.R-project.org/package=unhcrthemes)
Simplify the creation of your data visualizations with the `{unhcrthemes}` R package. It is designed to align your plots with [UNHCR's data visualization](https://dataviz.unhcr.org/guidance/) recommendations. This package offers a comprehensive `{ggplot2}` theme, including built-in customizations and thoughtfully crafted color palettes.
## Features
- A consistent and appealing `{ggplot2}` theme that matches [UNHCR Data Visualization Guidelines](https://dataviz.unhcr.org/guidance/).
- A collection of color palettes ensuring your plots are consistent with [UNHCR's color scheme](https://dataviz.unhcr.org/guidance/).
- Easy-to-use functions to apply the theme and color palettes to your `{ggplot2}` plots.
## Installation
Get started by installing the `{unhcrthemes}` package from CRAN with:
```{r install, eval=FALSE}
install.packages("unhcrthemes")
```
Or retrieve the development version from Github using the `{pak}` package:
```{r pak, eval=FALSE}
# If pak is not yet installed, uncomment the following line:
# install.packages("pak")
pak::pkg_install("unhcr-dataviz/unhcrthemes")
```
## Usage
```{r load, message = FALSE, warning = FALSE}
# Load required packages
library(ggplot2)
library(unhcrthemes)
```
### Base `{ggplot2}` theme
```{r base-plot, message = FALSE, warning = FALSE, out.width="90%", fig.align="center"}
# Apply the theme_unhcr() to your plot
ggplot(
mtcars,
aes(x = hp, y = mpg)
) +
geom_point() +
labs(
title = "Simple scatterplot with ggplot",
subtitle = "This plot shows the default style of theme_unhcr()",
x = "Horsepower (hp)",
y = "Fuel efficiency (mpg)",
caption = "Source: mtcars"
) +
theme_unhcr()
```
### Fonts
One of the two officially recommended fonts outlined in the [UNHCR Data Visualization Guidelines](https://dataviz.unhcr.org/guidance/) is [`Lato`](https://fonts.google.com/specimen/Lato). To ensure optimal functionality of the `{unhcrthemes}` package, please make sure that the `Lato` font is installed on your device prior to usage.
For `R` PDF (`pdf`) and PostScript (`postcript`) devices, there is a function `import_lato` that can be used to import the `Lato` font into these two devices. We recommend the use of `cairo_pdf` or `cairo_ps` devices, which work when you have `Lato` installed. They are available on all platforms and have better support custom fonts.
### Color palettes
Choose from a variety of carefully curated color palettes that harmonize with UNHCR's visual identity.
```{r palette-all, message = FALSE, warning = FALSE, out.width="90%", fig.align="center", fig.height=6}
# Display all unhcr color palette
display_unhcr_all()
```
```{r palette-blue, message = FALSE, warning = FALSE, out.width="90%", fig.align="center", fig.height=2}
# Or select a specific one and limit the number of colors
display_unhcr_pal(n = 3, "pal_blue")
```
### Scales (color/fill)
```{r scale-plot, message = FALSE, warning = FALSE, out.width="90%", fig.align="center"}
# Add color scale to your plot
ggplot(
mtcars,
aes(x = hp, y = mpg, color = as.factor(cyl))
) +
geom_point(alpha = .8) +
labs(
title = "Simple scatterplot with ggplot",
subtitle = "This plot shows the default style of theme_unhcr()",
x = "Horsepower (hp)",
y = "Fuel efficiency (mpg)",
color = "Number of cylinder",
caption = "Source: mtcars"
) +
scale_color_unhcr_d() +
theme_unhcr(legend_title = TRUE)
```
### Geoms (text/label)
```{r geom-plot, message = FALSE, warning = FALSE, out.width="90%", fig.align="center", fig.height=4}
# Default Lato font also apply for geom_text and label
dplyr::count(mpg, class) |>
dplyr::arrange(n) |>
dplyr::mutate(class = factor(class, levels = class)) |>
ggplot(aes(n, class)) +
geom_col(fill = unhcr_pal(n = 1, "pal_blue")) +
geom_text(aes(label = n), hjust = 0, nudge_x = 1) +
labs(
title = "Simple bar chart with labels using ggplot",
subtitle = "This plot shows the default style of theme_unhcr()",
caption = "Source: mtcars"
) +
scale_x_continuous(expand = expansion(c(0, 0.1))) +
theme_unhcr(grid = FALSE, axis = "y", axis_title = FALSE, axis_text = "y")
```
Explore more examples of `{unhcrthemes}` in action on the [package vignette](https://unhcr-dataviz.github.io/unhcrthemes/articles/unhcrthemes.html) or [UNHCR Data Visualization Platform](https://dataviz.unhcr.org/tutorials/r/).
```{r child="man/rmdfragments/unhcr_tools.Rmd"}
```
## Acknowledgements
We extend our gratitude to the creators of the [`{hrbrthemes}`](https://github.com/hrbrmstr/hrbrthemes), [`{rcartocolor}`](https://github.com/Nowosad/rcartocolor) and [`{cowplot}`](https://github.com/wilkelab/cowplot/) packages that influenced the development of `{unhcrthemes}`.
## Contribution and Code of Conduct
Contributions to `{unhcrthemes}` are highly valued. To ensure a welcoming and inclusive community, we follow our [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). If you have suggestions, uncover bugs, or envision new features, kindly submit an [issue on GitHub](https://github.com/unhcr-dataviz/unhcrthemes/issues). To contribute code, don't hesitate to fork the repository and create a pull request.
## License
This package is distributed under the [MIT License](https://github.com/unhcr-dataviz/unhcrthemes/blob/master/LICENSE.md).
Owner
- Name: UNHCR Dataviz
- Login: unhcr-dataviz
- Kind: organization
- Website: https://dataviz.unhcr.org/
- Repositories: 1
- Profile: https://github.com/unhcr-dataviz
A place for UNHCR data visualizations based on code.
GitHub Events
Total
- Create event: 3
- Release event: 2
- Issues event: 6
- Watch event: 10
- Delete event: 3
- Issue comment event: 2
- Push event: 22
- Pull request event: 4
- Pull request review event: 1
- Fork event: 1
Last Year
- Create event: 3
- Release event: 2
- Issues event: 6
- Watch event: 10
- Delete event: 3
- Issue comment event: 2
- Push event: 22
- Pull request event: 4
- Pull request review event: 1
- Fork event: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 6
- Total pull requests: 4
- Average time to close issues: over 1 year
- Average time to close pull requests: 3 days
- Total issue authors: 3
- Total pull request authors: 1
- Average comments per issue: 0.67
- Average comments per pull request: 0.0
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 4
- Average time to close issues: 8 days
- Average time to close pull requests: 3 days
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 0.5
- Average comments per pull request: 0.0
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- vidonne (4)
- zanmat (1)
- dickoa (1)
Pull Request Authors
- vidonne (4)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 149 last-month
- Total dependent packages: 0
- Total dependent repositories: 2
- Total versions: 5
- Total maintainers: 1
cran.r-project.org: unhcrthemes
UNHCR 'ggplot2' Theme and Colour Palettes
- Homepage: https://github.com/unhcr-dataviz/unhcrthemes
- Documentation: http://cran.r-project.org/web/packages/unhcrthemes/unhcrthemes.pdf
- License: MIT + file LICENSE
-
Latest release: 0.7.1
published 6 months ago
Rankings
Forks count: 8.7%
Stargazers count: 15.8%
Dependent repos count: 19.2%
Dependent packages count: 28.7%
Average: 31.5%
Downloads: 85.3%
Maintainers (1)
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.5 depends
- colorspace * imports
- ggplot2 * imports
- ragg * imports
- scales * imports
- showtext * imports
- sysfonts * imports
- systemfonts * imports
- directlabels * suggests
- ggforce * suggests
- ggtext * suggests
- knitr * suggests
- lubridate * suggests
- rmarkdown * suggests
- tidyverse * suggests
- treemapify * suggests
.github/workflows/check-standard.yaml
actions
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
.github/workflows/pkgdown.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
- r-lib/actions/setup-r-dependencies v1 composite