Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emilhvitfeldt/fontscales
Use Iconographic Fonts in 'ggplot2'
https://github.com/emilhvitfeldt/fontscales
Last synced: about 2 months ago
JSON representation
Use Iconographic Fonts in 'ggplot2'
- Host: GitHub
- URL: https://github.com/emilhvitfeldt/fontscales
- Owner: EmilHvitfeldt
- License: other
- Created: 2021-02-20T21:21:47.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-21T00:47:55.000Z (almost 4 years ago)
- Last Synced: 2023-03-01T05:32:28.207Z (almost 2 years ago)
- Language: R
- Size: 99.6 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
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%"
)
```# fontscales
[![R-CMD-check](https://github.com/EmilHvitfeldt/fontscales/workflows/R-CMD-check/badge.svg)](https://github.com/EmilHvitfeldt/fontscales/actions)
The goal of fontscales is to is to let you use fancy iconographic fonts with ease in [ggplot2](https://ggplot2.tidyverse.org/).
This package relies heavily on [ragg](https://ragg.r-lib.org/), please see [this article](https://www.tidyverse.org/blog/2021/02/modern-text-features/) for more information.
## Installation
You can install the dev version of fontscales from [Github](http://github.com/) with:
```{r installation, eval=FALSE}
require("devtools")
install_github("EmilHvitfeldt/fontscales")
```## StateFace
The [StateFace](https://propublica.github.io/stateface/) font by [ProPublica](https://www.propublica.org/) contains the 50 different U.S. states as tiny glyphs and can thus be used in data visualizations.
The data set `usa_arrests` represents a data set where this might be useful where the `state` variable contains the name of the state
```{r}
library(fontscales)
usa_arrests
```Using `ggplot2` you pass the state name variable to the `label` aesthetic and use `geom_stateface()` to draw the states. (This should function similary to `geom_text()` or `geom_point()`).
```{r}
library(ggplot2)
ggplot(usa_arrests, aes(murder, assault, label = state, color = urban_pop)) +
geom_stateface()
```And other `ggplot2` functions work as expected
```{r}
library(tidyr)
usa_arrests %>%
pivot_longer(-c(state, urban_pop)) %>%
ggplot(aes(urban_pop, value, label = state)) +
geom_stateface() +
facet_wrap(~name, scales = "free_y")
```