library(RSQLite) drv <- dbDriver("SQLite") dbfile <- "iwai.db" con <- dbConnect(drv, dbfile) dbListTables(con) res<-dbGetQuery(con, "SELECT * FROM iwai ;") x<-as.POSIXlt(res[,1]) r <-as.POSIXlt(range(x)) r1 <-as.Date(range(x)) title<-paste("鳥取 岩井温泉 ",r1[1],"~",r1[2]) par(mar = c(3,7,3,6),mfrow=c(2,1),cex.axis=0.9,family="TakaoMincho") plot(x,res$TempAve,xaxt="n",xlab = "Date", ylab = "", main = title,las = 1,type="l",col="red") grid(NA,NULL,lty=3) axis.POSIXct(1, at=seq(r[1],r[2],by="6 months"), format="%Y/%m") mtext("水温(℃)", side=2, line=4) abline(v=seq(r[1],r[2], by="6 months"),lty=3,col="gray") par(new=T) plot(x,res$RangeMax,xaxt="n",xlab="",yaxt="n",ylab="",type="h",ylim=c(0,2),col="blue",main="") axis(4,las=1) mtext("水位差(Max-Min)", side=4, line=3) plot(x,res$LevelAve,xaxt="n",xlab="",ylab="水位(m)",type="l",col="blue",ylim=c(NULL,NULL),main="",las=1) grid(NA,NULL,lty=3) axis.POSIXct(1, at=seq(r[1],r[2], by="6 months"), format="%Y/%m") abline(v=seq(r[1],r[2], by="6 months"),lty=3,col="gray") par(mfrow=c(1,1))
|