Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.06 KB

README.md

File metadata and controls

48 lines (33 loc) · 1.06 KB

ggflags: Plot flags of the world in ggplot2

A flag geom for ggplot2. Uses circular SVG flags.

Install

Install from R-Universe:

install.packages("ggflags", repos = c(
  "https://jimjam-slam.r-universe.dev",
  "https://cloud.r-project.org"))

Use

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, 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)