Skip to content

Instantly share code, notes, and snippets.

@thomasp85
Last active January 10, 2019 09:22
Show Gist options
  • Save thomasp85/74bbcf1ff8a3a37f3d2626750e664bdb to your computer and use it in GitHub Desktop.
Save thomasp85/74bbcf1ff8a3a37f3d2626750e664bdb to your computer and use it in GitHub Desktop.
air quality
library(gganimate)
airq <- airquality
airq$Month <- format(ISOdate(2004,1:12,1),"%B")[airq$Month]
ggplot(airq, aes(Day, Temp, group = Month)) +
geom_line() +
geom_segment(aes(xend = 31, yend = Temp), linetype = 2, colour = 'grey') +
geom_point(size = 2) +
geom_text(aes(x = 31.1, label = Month), hjust = 0) +
transition_reveal(Day) +
coord_cartesian(clip = 'off') +
labs(title = 'Temperature in New York', y = 'Temperature (°F)') +
theme_minimal() +
theme(plot.margin = margin(5.5, 40, 5.5, 5.5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment