library(ggplot2) library(scales) epw = "~/weather-datasets/GBR_London-Heathrow.AP.1989_2020High50pct_CIBSETM49.epw" system(paste("cat ",epw, "| tail -8760 > test.csv")) EPW <- read.csv("test.csv", header=FALSE) EPW$OAT = EPW[,7] EPW$RH = EPW[,9] EPW$MDH <- paste(EPW$V2,EPW$V3,EPW$V4) EPW$M = as.POSIXlt(EPW$MDH,format="%m") EPW$DT = as.POSIXlt(EPW$MDH,format="%m %d %H") EPW$HR = as.numeric(format(EPW$DT, "%H")) EPW$hum_ratio=((2.16679*((610.78*exp((EPW$OAT/(EPW$OAT+238.3))*17.2694))*(EPW$RH/100)/(273.15+EPW$OAT)))/1275.4) #temps <- data.frame() #for (i in 0:23) {temps <- rbind(temps,c( # i, # mean(subset(subset(EPW, HR==i), format(DT,'%m')=='12')$OAT), # mean(subset(subset(EPW, HR==i), format(DT,'%m')=='03')$OAT), # mean(subset(subset(EPW, HR==i), format(DT,'%m')=='06')$OAT), # mean(subset(subset(EPW, HR==i), format(DT,'%m')=='09')$OAT))) #} #colnames(temps) <- c("hr", "temp_dec", "temp_mar", "temp_jun", "temp_sep") pdf("physco2020.pdf") #ggplot(diamonds, aes(x=carat, y=price)) + geom_point() #ggplot(temps, aes(x=hr, y=temp_dec) + geom_point() #ggplot(mtcars) + geom_point(aes(x=mpg, y=drat, colour=gear)) #subset(EPW, format(DT,'%m')=='07') ggplot(EPW, aes(x = OAT, y = hum_ratio))+ geom_point(data=subset(EPW, format(DT,'%m')=='01'), alpha = 1.0,colour="blue")+ geom_point(data=subset(EPW, format(DT,'%m')=='02'), alpha = 0.05)+ geom_point(data=subset(EPW, format(DT,'%m')=='03'), alpha = 0.05)+ geom_point(data=subset(EPW, format(DT,'%m')=='04'), alpha = 0.05)+ geom_point(data=subset(EPW, format(DT,'%m')=='05'), alpha = 0.05)+ geom_point(data=subset(EPW, format(DT,'%m')=='06'), alpha = 0.05)+ geom_point(data=subset(EPW, format(DT,'%m')=='07'), alpha = 1.0,colour="red")+ geom_point(data=subset(EPW, format(DT,'%m')=='08'), alpha = 0.05)+ geom_point(data=subset(EPW, format(DT,'%m')=='09'), alpha = 0.05)+ geom_point(data=subset(EPW, format(DT,'%m')=='10'), alpha = 0.05)+ geom_point(data=subset(EPW, format(DT,'%m')=='11'), alpha = 0.05)+ geom_point(data=subset(EPW, format(DT,'%m')=='12'), alpha = 0.05)+ scale_x_continuous(limits = c(-10, 45))+scale_y_continuous(limits = c(0, 0.03)) #ggplot(EPW) + geom_point(aes(x=DT, y=HR, colour=factor(OAT)))+ #scale_y_reverse(expand = c(0,0),breaks = c(0:24),labels=c("0","","","3","","","6","","","9","","","12","","","15","","","18","","","21","","","24"), limits = c(24,0))+ # scale_x_datetime( # breaks = "1 month", # expand = c(0,0), # labels = date_format("%^b"), # limits=c(as.POSIXct('2015/05/01'),as.POSIXct('2015/10/1')))+ # theme( # panel.background = element_rect(fill = 'white'), # fill background white # panel.border = element_rect(fill=NA,colour = "#AAAAAA",size=2), # set size and colour of panel border # panel.grid.major = element_line(colour = "#B0B0B0"), # change grid line colour # panel.grid.minor.x = element_blank(), # remove x-axis minor gridlines # axis.text = element_text(size=10, colour = "#505050"), # set size and colour of axis text # axis.title.x = element_text(vjust=-3,size=10), # set position of x-axis title text # axis.title.y = element_text(vjust=+3,size=10), # set position of y-axis title text # plot.margin=unit(c(1,1,1.5,1.2),"cm"))+ # labs(color="")+xlab("Day of Year") +ylab("Hour of Day") #ggplot(EPW,aes(x = DT, y = HR, color = factor(OAT))+layer(geom = "point")) dev.off() #pdf("plots.pdf") #ggplot(EPW,aes(x=DT, y=HR, color=factor(OAT, layer(geom = "point")))) #dev.off() #)+scale_y_reverse(expand = c(0,0),breaks = c(0:24),labels=c("0","","","3","","","6","","","9","","","12","","","15","","","18","","","21","","","24"), limits = c(24,0)) # scale_x_datetime( # breaks = "1 month", # expand = c(0,0), # labels = date_format("%^b"), # limits=c(as.POSIXct('2015/05/01'),as.POSIXct('2015/10/1')))+ # scale_color_manual(values = c( # "+10"="#EA3A43","+8"="#EF611A","+6"="#F6913A", # "+4"="#FEC50E","+2"="#F1EC17","0"="#FEFEFE", # "-2"="#7EA4D8","-4"="#487ABE","-6"="#135CAB"))+ # # theme( # panel.background = element_rect(fill = 'white'), # fill background white # panel.border = element_rect(fill=NA,colour = "#AAAAAA",size=2), # set size and colour of panel border # panel.grid.major = element_line(colour = "#B0B0B0"), # change grid line colour # panel.grid.minor.x = element_blank(), # remove x-axis minor gridlines # axis.text = element_text(size=10, colour = "#505050"), # set size and colour of axis text # axis.title.x = element_text(vjust=-3,size=10), # set position of x-axis title text # axis.title.y = element_text(vjust=+3,size=10), # set position of y-axis title text # plot.margin=unit(c(1,1,1.5,1.2),"cm"))+ # # labs(color="")+xlab("Day of Year") +ylab("Hour of Day") # #dev.off()