if (require("ggplot2")) {
# 'circle' pattern example
df <- data.frame(level = c("a", "b", "c", 'd'), outcome = c(2.3, 1.9, 3.2, 1))
gg <- ggplot(df) +
geom_col_pattern(
aes(level, outcome, pattern_fill = level,
size = outcome, pattern_size = outcome),
pattern_density = 0.4,
pattern_spacing = 0.3,
pattern = 'circle',
fill = 'white',
colour = 'black'
) +
theme_bw(18) +
theme(legend.position = 'none') +
scale_pattern_size() +
labs(
title = "ggpattern::geom_col_pattern()",
subtitle = "pattern = 'circle'"
)
plot(gg)
}
Run the code above in your browser using DataLab