Hi, May be this helps: plot(dataset1~Date,data=mydata[!is.na(mydata$dataset1),],ylim=range(5.7,8),pch=10,cex=0.8,col="black",xlab="Date",ylab="pH") with(mydata[!is.na(mydata$dataset2),],points(Date,dataset2,col="blue",pch=2,cex=0.8)) with(mydata[!is.na(mydata$dataset3),],points(Date,dataset3,col="red",pch=2,cex=0.8)) with(mydata[!is.na(mydata$dataset1),],lines(Date,dataset1,lty=c(1),col="black")) with(mydata[!is.na(mydata$dataset2),],lines(Date,dataset2,lty=c(1),col="blue")) with(mydata[!is.na(mydata$dataset3),],lines(Date,dataset3,lty=c(1),col="red"))
A.K. ----- Original Message ----- From: David Doyle <kydaviddo...@gmail.com> To: r-help@r-project.org Cc: Sent: Saturday, May 11, 2013 10:22 PM Subject: [R] Broken line questions Hello Everyone, I have some data that like most real world data isn't complete. I'm trying to plot all of it together with lines connecting the data points. Because I have breaks in the data I have breaks in the lines. Is there a way that the lines will connect all the markers??? Below is the code. Thanks in advance. David #Load your data. The data is in a spreadsheet named KW-spreadsheet and we are going to call it "data" in R mydata <- read.csv("http://doylesdartden.com/example-smoothing-data.csv", sep=",") attach(mydata) #Plots the Y and X axis plot( Date, dataset1, #sets the range of the y axis ylim=range(5.7,8), #sets the symbol type, size, and color for the 1st series pch=10,cex=0.8, col='black', xlab="Date ", ylab="pH") #Plots the second series points( Date, dataset2, col='blue',pch=2, cex=0.8) #Plots the 3rd series points( Date, dataset3, col='red',pch=3, cex=0.8) #Lines lines(Date, dataset1, lty = c(1),col='black') lines(Date, dataset2, lty = c(2),col='blue') lines(Date, dataset3, lty = c(3),col='red') #Add Legend to graph. You can change the size of the box by changing cex = 0.75 Large # makes it larger. legend("bottomleft",c("Dataset1","Dataset2", "Dataset3"), col = c("black","blue", "red"), cex = 0.7,text.col = "black",lty = c(1,2,3),lwd=c(2),pch = c(10,2,3), merge = TRUE, bg = 'gray90') #Add title title(main="Time Series Plot") #done [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.