[R] How can I generate line segments between two sets of points on the same graph?

From: Lloyd Lubet <lloydl_at_cybermesa.com>
Date: Mon 15 Jan 2007 - 23:56:41 GMT


I am drawing two plots on the same graphics device window as follows:  

yLim<-range(range(template),range(slope*subSeries) )

plot( template, type="p", pch=19,cex=1.75,lwd=2.5,lty=1, ann=F, axes=F,frame.plot=T,col="red", ylim=yLim,new=T )

title( main = "myDotChart of original template and subSeries vs time" );points( slope*subSeries, type="p", pch=15,cex=1.35,lty=2,lwd=2.5, col="blue", ann=F )

I want to connect the two corresponding points at the same x-coordinate ( x-axes is shared by both plots essentially). I want to connect the template points to the subSeries points at each x-coordinate.

The x-axes is 1:30 in both plot and the points;

Here's an example for the 2 points trying to connect two points for the x-coordinate = 3:  

segments(3, template[3], 3,subSeries[3], col= "black",lwd=2)Now here's what I get: a black line from the x-axis to the point: c(3, template[3])In other words the above statement acts the same as: segments(3, template[3], 3, 0, col= "black",lwd=2);I cannot make segments or lines that connect two points at the same x-coordinate.I also tried this: segments(3.1, template[3], 2.9,subSeries[3], col= "black",lwd=2) whichstill drew a line starting at the x-axes, ignoring the subSeries[3] point altogether.How can I generate line segments between two sets of points on the same graph?Sincerely,Lloyd L

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch 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. Received on Tue Jan 16 11:02:07 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 16 Jan 2007 - 00:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.