I have found a new hobby - trying to recreate silly infographics by using ggplot2.
The purpose of this “chart” is twofold:
- demonstrate the relative merits of several Dutch delicacies (the fresh herring is in fact highly palatable, but suffers from a bad rep)
- practice labeling in ggplot and centering chart title
The code to generate the infographic is following:
library(ggplot2)
library(grid)
library(gridExtra)
srcData <- data.frame(duvody = c('stroopwafels', 'fresh herring','the cheese'),
hodnoty = c(100, 0, 100))
srcData$duvody <- factor(srcData$duvody, levels = c('stroopwafels', 'fresh herring','the cheese'))
dutchPlot <- ggplot(srcData, aes(x = rev(duvody), y = hodnoty, fill = duvody)) +
geom_col(width = 1) +
scale_fill_manual(values = c('the cheese' = 'royalblue4',
'stroopwafels' = 'red2',
'fresh herring' = 'orange1')) +
coord_flip() +
theme_light() +
theme(axis.title = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
legend.title = element_blank(),
panel.grid = element_blank(),
plot.title = element_text(size = rel(2.5), face = "bold", hjust = 0.5,
margin = margin(t = 10, b = 20, unit = "pt")))
grid.arrange(textGrob("Reasons to Love Dutch Food",
gp = gpar(fontsize = 2.5*11, fontface = "bold")),
dutchPlot,
heights = c(0.1, 1))