[R] Broken line questions

arun smartpink111 at yahoo.com
Sun May 12 05:01:39 CEST 2013

May be this helps:


----- Original Message -----
From: David Doyle <kydaviddoyle at gmail.com>
To: r-help at r-project.org
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.

#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",

#Plots the Y and X axis
plot( Date, dataset1,

#sets the range of the y axis

#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(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")

    [[alternative HTML version deleted]]

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list