Created
September 29, 2022 15:45
-
-
Save jmcastagnetto/993940489bf3c7cdbb50d3e418aea844 to your computer and use it in GitHub Desktop.
Simple barplot with labels on top (ggplot2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
) | |
Author
jmcastagnetto
commented
Sep 29, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment