Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/OCHA-DAP/gghdx

HDX Theme, Scales, and Other Conveniences for 'ggplot2'
https://github.com/OCHA-DAP/gghdx

Last synced: 3 days ago
JSON representation

HDX Theme, Scales, and Other Conveniences for 'ggplot2'

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# gghdx

[![R-CMD-check](https://github.com/OCHA-DAP/gghdx/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/OCHA-DAP/gghdx/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/OCHA-DAP/gghdx/branch/main/graph/badge.svg)](https://app.codecov.io/gh/OCHA-DAP/gghdx?branch=main)

## Overview

The goal of gghdx is to make it as simple as possible to follow the HDX visual
guidelines when creating graphs using ggplot2. While most of the functionality
is in allowing easy application of the HDX color ramps, the package also
streamlines some of the other recommendations and best practices regarding
plotted text, axis gridlines, and other visual features. The key functionalities
are:

* `theme_hdx()` is the general package theme.
* `scale_color_hdx_...()` and `scale_fill_hdx_...()` applies the HDX color scale to
the relevant aesthetics.
* `hdx_colors()`, `hdx_hex()`, and `hdx_pal_...()` provide easy user access to the
HDX color template. You can view the colors
* `geom_text_hdx()` and `geom_label_hdx()` wrap the respective base functions
to plot text using HDX fonts and aesthetics.
* `scale_y_continuous_hdx()` wraps `scale_y_continuous()` to plot data directly
starting from the y-axis.
* `gghdx()` ensures plot for the session use HDX defaults for color and fill
scales, uses `theme_hdx()` for all plots, and applies `scale_color_hdx_...()` and
`scale_fill_hdx_...()`
* `label_number_hdx()` and `format_number_hdx()` supplement the `scales::label_...()` series of functions
to format and create labels for numbers in the HDX style.

## Installation

You can install gghdx directly from CRAN:

```r
install.packages("gghdx")
```

You can install the development version from GitHub:

```r
## install.packages("remotes")
remotes::install_github("OCHA-DAP/gghdx")
```

```{r child="vignettes/gghdx.Rmd"}
```