Skip to content

Instantly share code, notes, and snippets.

@cavedave
Created September 9, 2019 11:13
Show Gist options
  • Save cavedave/19464c503c6119df7f47e84f477247a2 to your computer and use it in GitHub Desktop.
Save cavedave/19464c503c6119df7f47e84f477247a2 to your computer and use it in GitHub Desktop.
SouthernCal temperatures. Data from https://www.ncdc.noaa.gov/cdo-web/datatools/selectlocation Start Date 1918-09-01 End Date 2019-09-06 REQUESTED DATA Stations CHULA VISTA, CA US (GHCND:USC00041758)
df <- read.csv(file="1862381.csv",header=TRUE, sep=",")
df<-df %>%
dplyr::mutate(year = lubridate::year(DATE),
month = lubridate::month(DATE),
day = lubridate::day(DATE))
df=df[!is.na(df$TMAX),]
head(df)
Jul<-filter(df, month == 7)
tail(Jul,20)
Aug<-filter(df, month == 8)
tail(Aug,20)
Jul$Temp <- cut(Jul$TMAX, breaks=c(60,65,70,75,80,85,90,95, Inf), labels=c("60","65","70","75","80","85","90","95+"))
Aug$Temp <- cut(Aug$TMAX, breaks=c(60,65,70,75,80,85,90,95, Inf), labels=c("60","65","70","75","80","85","90","95+"))
hot <- c("#6BBCD1","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026","#800026")
library(ggplot2)
# Basic scatter plot
p<-ggplot(Aug, aes(x=year, y=TMAX , color=Temp)) + geom_point()#
p=p+ggtitle("Maximum Temperature each August Day in San Diego") +xlab("Year") + ylab("Max Temp °F")
p=p+geom_smooth(method=loess, colour="black")
# To use for line and point colors, add
#p=p + scale_colour_manual(values=cbp1) RdBu
p=p + scale_colour_manual(values=hot)
p=p + theme_bw()
p=p+theme(plot.title = element_text(hjust = 0.5))
p
ggsave("AugCal.png")
@cavedave
Copy link
Author

cavedave commented Sep 9, 2019

JulCal

@cavedave
Copy link
Author

cavedave commented Sep 9, 2019

AugCal

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