[R] Line Type Specification: lty="<on><off>" but lty="<off><on>"?

David Winsemius dwinsemius at comcast.net
Mon Oct 11 00:43:14 CEST 2010


On Oct 10, 2010, at 5:50 PM, Henrik Bengtsson wrote:

> Hi,
>
> Section 'Line Type Specification' in help(par) explains how you can do
> custom line types.  For example:
>
> plot(NA, xlim=c(0,1), ylim=c(0,1));
> abline(h=1/2, col="blue", lwd=2, lty="88");
>
> will draw a dashed line segment where the line is composed of 8 units
> of "on" (blue color) and 8 units of "off" (transparent), then
> repeated.
>
> Now I'd like to draw a second red line overlapping this one, but where
> the "gaps" are now red.  Technically, I think the following would
> define that:
>
> abline(h=1/2, col="red", lwd=2, lty="0880");
>
> that is 0 "on", 8 "off", 8 "on" (red color) and 0 "off", then  
> repeated.
>
> However, zeros are not allowed (actually, why not?)
>
> Any suggestions to draw one red and one blue dashed lines that, if
> overlapping, the the overlapping segments will be blue, red, blue,
> red, ...?

You might look at the code for color.scale.lines in package plotrix.  
It's not exactly what you asked for but Jim Lemon has figured out out  
how to change colors of connected segments.

-- 
David.
>
> /Henrik



More information about the R-help mailing list