library('pacman') p_load('ggplot2') p_load('solaR') p_load('stringr') p_load('lubridate') p_load(scales) p_load(TTR) sol = readRDS(file="sol.Rda") irradiance <- function(lat,alfa) { g = calcGef( lat, # latitude argument modeTrk='fixed', # does not track the sun modeRad='bdI', # daily irradiance dfI2Meteo(sol, time.col = 'timestamp', lat=lat, format='%Y-%m-%d %H:%M:%S'), keep.night=TRUE, sunGeometry='michalsky', beta=90, alfa=alfa, corr='none', iS=2, alb=0.0) g = as.data.frameI(g)[c('Gef','Def','Bef')] # make as dataframe # g =tail(head(g,n=3000),n=24) # g = data.frame(timestamp=as.POSIXct(ymd_hms(rownames(g))),G0=g$Gef,D0=g$Def,B0=g$Bef) assign(paste("df"), g, envir= .GlobalEnv) } irradiance(52,90) head(df, n=30) df=df[!(df$G0<100),] df$timestamp = as.POSIXct(df$timestamp,format="%Y-%m-%d %H:%M:%S") # extract Date.Time df$hour = as.numeric(format(df$timestamp, "%H")) # add hour column df$cat =ifelse(df$G0 < 100, "<100", ifelse(df$G0 > 1 & df$G0 < 200, "100-200", ifelse(df$G0 > 200 & df$G0 < 300, "200-300", ifelse(df$G0 > 300 & df$G0 < 400, "300-400", ifelse(df$G0 > 400 & df$G0 < 500, "400-300", ifelse(df$G0 > 500 & df$G0 < 600, "500-600", ifelse(df$G0 > 600 & df$G0 < 700, "600-700", ifelse(df$G0 > 700 & df$G0 < 800, "700-800", ifelse(df$G0 > 800 & df$G0 < 900, "800-900", ifelse(df$G0 > 900 , ">900", "X")))))))))) head(df, n=20) pdf("graph.pdf",width=20, height=4.2) ggplot(df,aes(x = timestamp, y = hour))+ geom_point(aes(colour=G0))+ scale_y_reverse(expand = c(0,0),breaks = c(0:24), labels=c( "0","","","3","","","6","","", "9","","","12","","","15","","", "18","","","21","","","24"), limits = c(22,4))+ scale_x_datetime(breaks = "1 month",expand = c(0,0),labels = date_format("%^b"))+ 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() #df = rbind(g138,g48,g42,g132) #pdf('stack3.pdf') #ggplot(df, aes(x = time, y = G, fill = Z,)) + #geom_area(position = 'stack') ##xlim(1486960000, 1486971200) #dev.off() #df2 = df*A*G #df2$time = as.numeric(ymd_hms(rownames(df2))) #df2$time = as.numeric(df2$time)