# A tibble: 4 × 2
cup caffeine
<chr> <dbl>
1 Coffee 99
2 Tea 34
3 Green Tea 34
4 Decaf Tea 4
Now we can plot the caffeine meter using ggplot2:
library(ggplot2)g <-ggplot(caffeine_meter) +geom_col(aes(x = cup, y = caffeine, fill = cup))g
Then I add the colours that I extracted with GIMP:
pal <-c("#f444b3", "#3004c9", "#85d26a", "#3a5dff")g +scale_fill_manual(values = pal)
The Decaf Tea category should be at the end of the plot, so I need to transform the “cup” column to a factor sorted decreasingly by the “caffeine” column:
library(forcats)caffeine_meter <- caffeine_meter %>%mutate(cup =fct_reorder(cup, -caffeine))g <-ggplot(caffeine_meter) +geom_col(aes(x = cup, y = caffeine, fill = cup)) +scale_fill_manual(values = pal)g
Now I can change the background colour to a more blueish gray:
g +theme(panel.background =element_rect(fill ="#dcecfc"))
Now I need to add the title with a blue background, so putting all together: