https://github.com/jimjam-slam/ggflags
A flag geom for ggplot2. Tweaks the original by using round flags (great for plotting as points).
https://github.com/jimjam-slam/ggflags
dataviz flags ggplot2 ggplot2-enhancements r rstats
Last synced: 12 months ago
JSON representation
A flag geom for ggplot2. Tweaks the original by using round flags (great for plotting as points).
- Host: GitHub
- URL: https://github.com/jimjam-slam/ggflags
- Owner: jimjam-slam
- Fork: true (ellisp/ggflags)
- Created: 2017-08-31T12:46:33.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-06-03T11:23:55.000Z (almost 2 years ago)
- Last Synced: 2024-06-22T05:03:33.592Z (over 1 year ago)
- Topics: dataviz, flags, ggplot2, ggplot2-enhancements, r, rstats
- Language: R
- Homepage:
- Size: 41.5 MB
- Stars: 91
- Watchers: 6
- Forks: 14
- Open Issues: 15
-
Metadata Files:
- Readme: README.Rmd
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%"
)
```
## ggflags: Plot flags of the world in ggplot2
A flag geom for ggplot2. Uses circular SVG flags.
# Install
Install from R-Universe:
```r
install.packages("ggflags", repos = c(
"https://jimjam-slam.r-universe.dev",
"https://cloud.r-project.org"))
```
# Use
```{r demo, warning=FALSE}
library(ggplot2)
library(ggflags)
set.seed(1234)
d <- data.frame(
x = rnorm(50), y = rnorm(50),
country = sample(c("ar", "fr", "nz", "gb", "es", "ca", "lv", "qa"), 50, TRUE),
stringsAsFactors = FALSE
)
ggplot(d, aes(x = x, y = y, country = country, size = x)) +
geom_flag() +
scale_country() +
scale_size(range = c(0, 15))
```
The flag SVG assets, used under the [CC-BY licence](https://github.com/eosrei/emojione-color-font/blob/master/LICENSE-CC-BY.txt), are taken from the EmojiOne set: https://github.com/eosrei/emojione-color-font
(Note: the EmojiOne set doesn't include UK counties or US states!)

(note: proof of principle only)