[R] Vector lty argrument for lines or plot

Brian Diggs diggsb at ohsu.edu
Thu Nov 20 21:24:52 CET 2008


I am confused by the behavior of the lines function when the lty argument is a vector.  ?lines indicates that lty is a valid parameter, but says nothing else about it.  ?plot.xy (which I think is what gets called) refers back to ?lines.  ?plot.default says to see ?par.  In ?par, about lty it says "Some functions such as lines accept a vector of values which are recycled. Other uses will take just the first value if a vector of length greater than one is supplied."  However, I cannot get lines to use more than one type of line.  Some example code:

pt <- runif(10)
plot(pt) 
lines(pt, type="c", lty=1:10)

I expected each subsequent line segment to be in a different style.  Only the first seems to be used.  The same is true for plot:

plot(pt, type="b", lty=1:10)

uses only one style of line segment (although no documentation says explicitly that the others would be used).  It doesn't matter the order or manner of specification, only the first is used.

plot(pt)
lines(pt, type="c", lty=c("dashed","solid"))

plot(pt)
lines(pt, type="c", lty=c("FF", "11"))

I have used a vector of lty before (in legend) and it cycled through all the values.  Am I misunderstanding what a vector lty to lines means, or is this a bug?

I'm running on Windows XP Pro, if that might matter.

> sessionInfo()
R version 2.8.0 (2008-10-20) 
i386-pc-mingw32 

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

--
Brian Diggs, Ph.D.
Senior Research Associate, Department of Surgery, Oregon Health & Science University





More information about the R-help mailing list