pictogram example
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

#' ---
#' title: ""
#' author: ""
#' date: ""
#' output:
#' html_document:
#' keep_md: true
#' theme: simplex
#' highlight: monochrome
#' ---
#+ init, include=FALSE
knitr::opts_chunk$set(message = FALSE, warning = FALSE, dev="png", collapse=TRUE,
fig.retina = 2, fig.width = 10, fig.height = 6)
#+ libs
library(hrbrthemes)
library(waffle) # install from github/etc.
library(tidyverse)
xdf <- read_csv(here::here("data/ghlp.csv"), col_types = "cdd")
#+ fig.width=1600/72, fig.height=800/72
mutate(xdf, category = fct_inorder(category)) %>%
gather(measure, value, -category) %>%
mutate(measure = factor(measure, levels=c("female", "male"))) %>%
ggplot(aes(label = measure, values = value)) +
geom_pictogram(n_rows = 1, aes(colour = measure), show.legend = FALSE) +
scale_x_continuous(expand=c(0,0)) +
scale_y_continuous(expand=c(0,0)) +
scale_colour_manual(
values = c(
"female" = "#09394c",
"male" = "#a8a8a8"
)
) +
scale_label_pictogram(
name = NULL,
values = c("female", "male"),
labels = c("female", "male")
) +
facet_wrap(~category, ncol = 1) +
theme_ipsum_es(grid="", panel_spacing = unit(0, "lines")) +
theme_enhance_waffle()