Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
811 views
in Technique[技术] by (71.8m points)

r - Reason for strange gap in the plot

I have this plot of Depths vs time: This plot has a strange gap at the start of May.

enter image description here

I checked the data but there are no NAs or Nans or no missing data. This is a time series of regular interval of 15 minutes

I cannot give the dataset here since it contains 10,000 rows. Can somebody please give suggestions as what possibly it can be?

I am using the following plotting code:

   library(zoo)
   z=read.zoo("data.txt", header=TRUE)
   temp=index(z[,1])
   m=coredata(z[,1])
x=0.001
p=rep.int(x,length(temp))
png(filename=paste(Name[k],"_mean1.png", sep=''), width= 3500, height=1600, units="px")
par(mar=c(13,13,5,3),cex.axis= 2.5, cex.lab=3, cex.main=3.5, cex.sub=5)
plot(temp,m, xlab="Time", ylab="Depth",type='l', main=Name[k])
symbols(temp,m,add=TRUE,circles=p, inches=1/15, ann=F, bg="steelblue2", fg=NULL)
dev.off()
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Okay, here's a guess from what you have posted.

I'm guessing there is no data for a period right at the start of May where the 'gap' in question pops up. There are no NAs because there just aren't any lines of data for this period at all. There is still a thin black line drawn to the plot by this line of code which links the 'gap' in data...

plot(temp,m, xlab="Time", ylab="Depth",type='l', main=Name[k])

...but there are no blue symbols (circles) plotted close together enough to make it look like a continuous blue line. The blue symbols being plotted with the below code, over the top of the existing plot:

symbols(temp,m,add=TRUE,circles=p, inches=1/15, ann=F, bg="steelblue2", fg=NULL)

I suggest instead of plotting a line and then plotting symbols over the top of it that you just plot a thick blue line to start with like:

plot(temp,m, xlab="Time", ylab="Depth",type='l', main=Name[k],lwd=5,col="steelblue2")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...