Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/MilesMcBain/inlegend

Styling for inset ggplot2 map legends
https://github.com/MilesMcBain/inlegend

Last synced: about 2 months ago
JSON representation

Styling for inset ggplot2 map legends

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%"
)
```

# inlegend

`ggplot2` theming helpers for making static maps with inset legends:

* `inset_legend_dark()`
* `inset_legend_light()`
* `theme_cropped_map()`

## Installation

From [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("milesmcbain/inlegend")
```

## Example

```{r example, fig.cap = "Bike share capacity, London. Via {spData}", dpi = 200, fig.width = 8}
library(spData)
library(snapbox) ##remotes::install_github("anthonynorth/snapbox")
library(ggplot2)
library(ggspatial)
library(sf)
library(inlegend)
library(stylebox)
ggplot() +
layer_mapbox(
spData::cycle_hire_osm,
stylebox::mapbox_gallery_frank()
) +
layer_spatial(spData::cycle_hire_osm,
aes(colour = capacity),
alpha = 0.75) +
scale_colour_viridis_b() +
inset_legend_light("top-right") +
theme_cropped_map()
```