从这里找到的帮助我设法创建了这个多时隙面板:
使用以下代码:
library(zoo)
library(ggplot2)
datos=read.csv("paterna.dat",sep=";",header=T,na.strings="-99.9")
datos$dia=as.POSIXct(datos[,1], format="%y/%m/%d %H:%M:%S")
datos$Precipitación[is.na(datos$Precipitación)]=0
xlim = as.POSIXct(c("2010-05-12 00:00:00", "2010-05-12 23:50:00"))
ylim = trunc(max(datos$Precipitación) + 5)
tmax = trunc(max(datos$Temperatura) + 5)
tmin = trunc(min(datos$Temperatura) - 5)
tmx = max(datos$Temperatura)
tmxpos=which.max(datos$Temperatura)
tmn = min(datos$Temperatura)
tmnpos=which.min(datos$Temperatura)
tmp=ggplot(data=datos,aes(x=dia, y=Temperatura)) + geom_line(colour="red") + ylab("Temperatura (ºC)") +
xlab(" ") + scale_x_datetime(limits=xlim ,format = "%H",major='hour') + scale_y_continuous(limits = c(tmin,tmax)) + geom_text(data=datos[tmxpos,], label=tmx, vjust=-1.5, colour="red") + geom_text(data=datos[tmnpos,], label=tmn, vjust=1.5, colour="blue")
pre=ggplot(data=datos,aes(x=dia, y=Precipitación)) + geom_bar(colour="blue",stat="identity",fill="blue") +
ylab("Precipitación (l)") + xlab("Hora solar") + scale_x_datetime(limits=xlim ,format …Run Code Online (Sandbox Code Playgroud) I am using grid.layout() function to arrange a number of plots in one single figure. However, I do not know how to add a main title for the whole figure (at the mid-top of the figure)?
有人知道这一点并且可以帮助我吗?非常感谢!