Hello everyone, This is just a quick double check. It concerns the 'scatterplot function' in R. I have 6 curves and I wish to represent each of them by a different kind of line (their colour must be black). The curves are derived from the cuminc function...the coordinates of which are in 'xx'. Upon reading the documentation in R, it looks like I can use the 'on/off' command for lty and I can merely run: plot(xx,color="black",lty=c("11","13","1343","73","2262","35")) according to the documentation, "13" (for example) means 1 'on' and 3 'off' . Does the above look OK ? Say, in another study, I wish to draw my 6 lines all in different colours (solid lines), I suppose that I could type: plot(xx, color=c("red","black","purple","yellow","brown","violet"), lty=1) Thanks so much for your help, All the Best, Kim
While it is possible to set your own dash patterns as you show below, it is unlikely that the resulting graph will be very meaningful. Most people cannot keep the detailed dash patterns separate, and if they need to refer to a legend then it makes it even harder (See Bert Gunter's rant on the "Symbols in R" thread). If the curves are distinct enough it is best to just have them all black and solid and label the different lines. If that does not work then maybe using trellis style graphs where each line is in its own panel would be better (and still solid). Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of K F Pearce > Sent: Tuesday, June 08, 2010 4:45 AM > To: r-help at r-project.org > Subject: [R] scatterplot function - double check: dashed lines > > Hello everyone, > > This is just a quick double check. It concerns the 'scatterplot > function' in R. > > I have 6 curves and I wish to represent each of them by a different > kind of line (their colour must be black). > > The curves are derived from the cuminc function...the coordinates of > which are in 'xx'. > > Upon reading the documentation in R, it looks like I can use the > 'on/off' command for lty and I can merely run: > > plot(xx,color="black",lty=c("11","13","1343","73","2262","35")) > > according to the documentation, "13" (for example) means 1 'on' and 3 > 'off' . > > Does the above look OK ? > > Say, in another study, I wish to draw my 6 lines all in different > colours (solid lines), I suppose that I could type: > > plot(xx, color=c("red","black","purple","yellow","brown","violet"), > lty=1) > > Thanks so much for your help, > All the Best, > Kim > > ______________________________________________ > R-help at 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.
On 06/08/2010 08:44 PM, K F Pearce wrote:> Hello everyone, > > This is just a quick double check. It concerns the 'scatterplot function' in R. > > I have 6 curves and I wish to represent each of them by a different kind of line (their colour must be black). > > The curves are derived from the cuminc function...the coordinates of which are in 'xx'. > > Upon reading the documentation in R, it looks like I can use the 'on/off' command for lty and I can merely run: > > plot(xx,color="black",lty=c("11","13","1343","73","2262","35")) > > according to the documentation, "13" (for example) means 1 'on' and 3 'off' . > > Does the above look OK ? > > Say, in another study, I wish to draw my 6 lines all in different colours (solid lines), I suppose that I could type: > > plot(xx, color=c("red","black","purple","yellow","brown","violet"), lty=1) >Hi Kim, It depends upon what the object(s) are that contain the values for the curves. If these are in a matrix or data frame, you would probably want: plot(xx[,1],type="l",lty="11") lines(xx[,2],lty="13") Although I agree with Greg, and find myself scratching my glabella in confusion when I have to decipher plots like that. If the lines are separated at the right edge of the plot, you might try leaving some extra margin there and labeling them as Greg suggested. You can get a combination of these effects with something like this: matplot(cbind(sort(rnorm(10)),sort(rnorm(10))),col=2:3,type="b") Jim