Skip to content

Instantly share code, notes, and snippets.

@cavedave
Created July 17, 2017 13:34
Show Gist options
  • Save cavedave/a7edd8d535ffb2b3c248771c7592dcfa to your computer and use it in GitHub Desktop.
Save cavedave/a7edd8d535ffb2b3c248771c7592dcfa to your computer and use it in GitHub Desktop.
oxford<-read.csv('oxforddata.csv', sep=',', header=TRUE)
options(digits=2)
oxford$min <- as.numeric(as.character(oxford$tmin))
oxford$tmax <- as.numeric(oxford$tmax)
oxford <- oxford %>% mutate(average = (tmax+min)/2)
mins<-min(oxford$average)
maxs<-max(oxford$average)
oxford <- oxford %>% mutate(month =month.abb[mm])
oxford$months<-factor(rev(oxford$month),levels=rev(unique(oxford$month)))
head(oxford)
myPlot <- ggplot(oxford,aes(x = average,y=months,height=..density..))+
geom_joy(scale=3) +
scale_x_continuous(limits = c(mins,maxs))+
theme_joy() +
labs(x = "Average Temperature °C")+
theme(axis.title.y=element_blank(),
axis.ticks.y=element_blank(),
strip.text.y = element_text(angle = 180, hjust = 1))+
labs(title='Temperatures in Oxford, UK',
subtitle='Temperatures by month since 1853 by @iamreddave')
#ggsave("Dublin.png",type = "cairo")
ggsave(filename="Oxford1853.png", plot=myPlot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment