Как я могу изменить формат и масштаб оси X, используя данные даты и времени и .POSIXct? - PullRequest
0 голосов
/ 30 апреля 2020

Как я могу настроить шкалу оси X, используя дату и время. Я хотел бы настроить в формате год-месяц-день («% y-% m-% d»). Как я могу это сделать?

У меня есть эти данные:

flow<-rep(5, times = 839)
rain<-rep(0, times = 839)
#### create the time serie with data each five minutes for to graph with df data
dates<-seq(from=as.POSIXct("2018-08-14 11:05:00"), to= as.POSIXct("2018-08-17 08:55:00") ,by="5 min")
#### the data of rain and streamflow 
####for to graph a time serie data with "dates". 
#I put a sample of de real data (839 dates). 
#####Plot rainfall first and to solve the too large error
par(xaxs="i", yaxs="i", mar=rep(2,2))
######plot rain 
plot(dates, rain, type="h", ylim=c(max(rain)*10,0),
     axes=FALSE, xlab=NA, ylab=NA, col="gray", 
     lwd=20, lend="square")
####d
axis(4)
mtext("Precipitación", side=4, line=3)
#### Plot flow on top
par(new=TRUE)
####
plot(dates, flow, type="l", lwd=2, ylim=c(4, max(flow)*1.2), xlab = "Fecha", ylab = expression("Caudal (l/s)"), col="blue")

Мой сюжет

enter image description here

Спасибо.

...