Created
September 30, 2017 22:08
-
-
Save swayson/d4bbaca66233f271de4232d211b07c84 to your computer and use it in GitHub Desktop.
An example of a minimalistic barchart using 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) | |
airquality %>% | |
group_by(Month) %>% | |
summarise(average_temperature = mean(Temp)) %>% | |
ggplot(aes(x=Month, y=average_temperature)) + | |
geom_bar(stat='identity', position = 'dodge') + | |
geom_text(aes(label=round(average_temperature, 0)), position=position_dodge(width=0.9), vjust=-0.5) + | |
labs(x='Month', y='Average temperature', title='Average temperature per month') + | |
theme_minimal() + | |
theme(plot.background = element_blank(), | |
axis.ticks.x = element_blank(), | |
axis.ticks.y = element_blank(), | |
panel.grid.minor.y = element_blank(), | |
panel.grid.minor.x = element_blank(), | |
panel.grid.major.x = element_blank(), | |
axis.text.y = element_blank()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: