Polygon with different line width (in R)

Posted by Tal Galili on Stack Overflow See other posts from Stack Overflow or by Tal Galili
Published on 2010-04-29T07:05:02Z Indexed on 2010/04/29 7:07 UTC
Read the original article Hit count: 363

Filed under:
|
|

Hi all,

I would like to use a command like this:

plot(c(1,8), 1:2, type="n")
polygon(1:7, c(2,1,2,NA,2,1,2),
         col=c("red", "blue"),
         # border=c("green", "yellow"),
         border=c(1,10),
         lwd=c(1:10))

To create two triangles, with different line widths.

But the polygon command doesn't seem to recycle the "lwd" parameter as it does the col or the border parameters.

I would like the resulting plot to look like what the following code will produce:

plot(c(1,8), 1:2, type="n")
polygon(1:3, c(2,1,2),
         col=c("red"),
         # border=c("green", "yellow"),
         border=c(1,10),
         lwd=c(1))
polygon(5:7, c(2,1,2),
         col=c( "blue"),
         # border=c("green", "yellow"),
         border=c(1,10),
         lwd=c(10))

So my questions are:

Is there something like polygon that does what I asked for?

(If not, I would do it by creating a new polygon function that will break the original x,y by their NA's, although I am not yet sure what is the smartest way to do that...)

Thanks,

Tal

© Stack Overflow or respective owner

Related posts about r

    Related posts about plot