2015-08-20 2 views
0

Когда я позволю plot нарисовать ось, grid совпадает с ticksby default.Выровнять сетку с тиками

Однако мой сюжет несколько запутан:

mytime <- as.POSIXct("2015-08-20") + seq(0,by=3600,length.out=7*24) 
plot(x=mytime,y=rnorm(7*24),xaxt="n") 
ticks <- mytime[seq(1,by=12,to=length(mytime))] 
axis(1, ticks, strftime(ticks, "%a %H:%M")) 
grid(ny=NULL,nx=14) 

, и я не могу получить grid для согласования с ticks:

grid and ticks do not align

Как сделать их выровнять?

ответ

0

Похоже ответ:

mytime <- as.POSIXct("2015-08-20") + seq(0,by=3600,length.out=7*24) 
plot(x=mytime,y=rnorm(7*24),xaxt="n") 
ticks <- c(mytime[seq(1,by=12,to=length(mytime))],mytime[1]+7*24*3600) 
axis(1, ticks, strftime(ticks, "%a %H:%M")) 
grid(ny=NULL,nx=NA) 
abline(v=ticks[seq(1,length(ticks),2)],lty="dotted",col="lightgray") 

enter image description here

Смежные вопросы