Description Usage Arguments Examples
View source: R/i_geom_prop_label_in_ts.R
Percentage labels the are filled according to proportion where total in x is denominator
1 2 3 4 5 6 7 8 9 |
... |
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 26 27 28 29 30 31 32 33 34 35 36 37 38 | library(ggplot2)
library(magrittr)
gapminder::gapminder %>%
dplyr::mutate(gdp = gdpPercap * pop) %>%
ggplot() +
aes(x = year) +
aes(y = continent) +
geom_tile_prop_over_time() +
aes(fill = gdp) +
scale_fill_viridis_c() +
aes(label = gdp) +
geom_tile_prop_over_time_text()
gapminder::gapminder %>%
dplyr::mutate(gdp = gdpPercap * pop) %>%
ggplot() +
aes(x = year) +
aes(y = continent) +
geom_tile_prop_over_time() +
aes(fill = gdp) +
scale_fill_viridis_c() +
aes(label = gdp) +
geom_tile_prop_over_time_text(size = 2, angle = -90,
color = "snow") +
facet_wrap(facets = vars(pop > 1000000))
gapminder::gapminder %>%
ggplot() +
aes(x = year) +
aes(y = continent) +
aes(fill = 1, label = 1) + # use 1 to count times continent is observed
geom_tile_prop_over_time(color = "oldlace") +
labs(fill = "proportion\nof countries\nin each time\nperiod") +
i_geom_tile_prop_over_time_text(size = 3) +
facet_wrap(facets = vars(ifelse(gdpPercap > 10000,
"gdp per cap > 10000", "gdp per cap < 10000")),
ncol = 1) +
scale_fill_viridis_c()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.