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

Henrik Bengtsson hb at stat.berkeley.edu
Mon Oct 11 02:19:27 CEST 2010


Thanks both, but unfortunately not.

Here is a better illustration on what I want to achieve;

xs <- c(0,1,2,3); ys <- c(-1,0,0,1);
lty <- c("FF11", "1FF1");
plot(NA, xlim=c(0,3), ylim=c(-1,1));
lines(xs, ys, col="red", lwd=2, lty=lty[1]);
lines(xs, -ys, col="blue", lwd=2, lty=lty[2]);

except that I don't want those short "1":s pieces.  Ideally I'd like to use:

lty <- c("FF00", "0FF0");

and dashes of any lengths, e.g. lty <- c("2200", "0220");

/Henrik

On Sun, Oct 10, 2010 at 3:42 PM, Peter Alspach
<Peter.Alspach at plantandfood.co.nz> wrote:
> Tena koe Henrik
>
> Not exactly what you are requesting but you could draw a solid line and then the dashed line over the top:
>
> plot(1:10, panel.first=abline(0, 1, col='red', lwd=2), panel.last=abline(0, 1, col='blue', lty='88', lwd=2))
>
> or
>
> plot(1:10)
> abline(0, 1, col='red', lwd=2)
> abline(0, 1, col='blue', lty='88', lwd=2))
>
> This may be system or graphics device dependent (I'm using Windows).
>
> HTH ....
>
> Peter Alspach
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
>> project.org] On Behalf Of Henrik Bengtsson
>> Sent: Monday, 11 October 2010 10:50 a.m.
>> To: r-help
>> Subject: [R] Line Type Specification: lty="<on><off>" but
>> lty="<off><on>"?
>>
>> 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, ...?
>>
>> /Henrik
>>
>> ______________________________________________
>> 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.
>
> The contents of this e-mail are confidential and may be subject to legal privilege.
>  If you are not the intended recipient you must not use, disseminate, distribute or
>  reproduce all or any part of this e-mail or attachments.  If you have received this
>  e-mail in error, please notify the sender and delete all material pertaining to this
>  e-mail.  Any opinion or views expressed in this e-mail are those of the individual
>  sender and may not represent those of The New Zealand Institute for Plant and
>  Food Research Limited.
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list