Description Usage Arguments Value Note References Examples
View source: R/axis_icon_labels.R
Add X-Axis flags to ggplots
1 2 3 4 5 6 7 8 9 10 11 | geom_axis_flags(
breaks,
labels,
country_icons,
axis = "x",
icons_only,
width = 50,
lineheight = 3,
fontface = "bold",
...
)
|
breaks |
x axis breaks |
labels |
vector of labels to depict |
country_icons |
country for which flag to depict, in capital letter ISO-3 format (e.g. DEU for Germany) |
axis |
"x" or "y", defaults to "x" |
width |
width of the flag, defaults to 50 |
lineheight |
height of the axis label line |
fontface |
Font Face for Labels, defaults to "bold" |
adds x axis flags to ggplot
You must not call a ggplot theme after the call of geom_axis_flags, otherwise the theme parameter necessary for flag rendering will be overwritten.
Flags are under CC-BY licence and are obtained from: https://github.com/eosrei/emojione-color-font
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | options(tidyverse.quiet = TRUE)
library(tidyverse)
library(ggoxford)
library(ggtext)
wpop2013 <-
tidyr::population %>%
filter(year == 2013) %>%
filter(population > 1e6) %>%
mutate(iso3 = countrycode::countrycode(country,
origin = "country.name.en",
destination = "iso3c")
) %>%
slice(1:10)
head(wpop2013,10)
ggplot(data = wpop2013 ,
aes(x = iso3, y = population)) +
geom_bar(stat = "identity") +
theme_minimal() +
geom_axis_flags(breaks = wpop2013$iso3,
labels = wpop2013$country,
country_icons = wpop2013$iso3,
width = 30,
lineheight = 2,
fontface = "bold"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.