Skip to content

Instantly share code, notes, and snippets.

@jmcastagnetto
Created September 29, 2022 15:45
Show Gist options
  • Save jmcastagnetto/993940489bf3c7cdbb50d3e418aea844 to your computer and use it in GitHub Desktop.
Save jmcastagnetto/993940489bf3c7cdbb50d3e418aea844 to your computer and use it in GitHub Desktop.
Simple barplot with labels on top (ggplot2)
library(tidyverse)
library(palmerpenguins)
ggplot(
penguins,
aes(y = species, group = sex, fill = sex)
) +
geom_bar(width = .4) +
geom_text(aes(label = paste("Penguin species:", species), x = 0), nudge_y = .3, hjust = 0, size = 6) +
theme_void() +
theme(
plot.background = element_rect(color = "white", fill = "white"),
legend.position = c(.8, .5)
)
@jmcastagnetto
Copy link
Author

Barplot with labels on top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment