From paul@stat.auckland.ac.nz  Tue Jul 10 23:58:30 2001
From: paul@stat.auckland.ac.nz (Paul Murrell)
Date: Wed, 11 Jul 2001 10:58:30 +1200
Subject: [Rd] segments(*, col = c(..,NA,..)) {was "color NA ..."}
References: <15179.4603.473221.604700@gargle.gargle.HOWL> <15179.14016.810372.917441@gargle.gargle.HOWL>
Message-ID: <014901c10993$d642f780$175dd882@stat.auckland.ac.nz>

Hi


> Note however the following `misbehavior' (I think)  of segments() :
>
>  n <- 8
>  x <- 1:n
>  ep <- 0.2
>  cc <- c(1:4,NA,6:n)
>
>    plot(x, col= cc, type='h')
>  points(x, col= cc, cex=2)
>
>  segments(x+ep, x[1], x+ep, x[n], col = cc)# *does* draw at 5+ep ..
>
> ------
>
> i.e. segments does not follow the general idea of
>  ``not drawing when color is NA ''
>
> (note that there is no compatibility issue here, since S-plus
>  does not allow NA colors--and vectorized ones in most cases--anyway.)
>
> And this seems to be ``on purpose'' :
> in  src/main/plot.c  in do_segments(), around line 1560, we have
>
>     dd->gp.col = INTEGER(col)[i % ncol];
>     if (dd->gp.col == NA_INTEGER)
> dd->gp.col = dd->dp.col;
>
> which means in S language that col = NA will be translated to col =
par("col")
> Any reason why this would be a good idea ?


>From my memory of these things, this is how col=NA used to be treated in all
sorts of graphics functions.   In other words, segments() behaves like this
only because it hasn't been converted yet to the "new" interpretation of
col=NA (i.e., don't draw anything).

Paul

p.s.  we run into a bit of trouble with this issue for rect() and polygon().
Both use col=NA to indicate that the rect/polygon should not be FILLED, but
will still draw a border.  And its not so easy to just change the meaning of
col=NA -- we need to find a new way of specifying "don't fill, but do draw
the border".  One option would be col=NULL (?)

p.p.s.  rect(border=NA) doesn't draw a border, but will still fill the
rectangle.

p.p.s. polygon(border=NA) DOES draw a border in border=par(fg) -- you have
to use polygon(border=0) NOT to draw a border.


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] segments(*, col = c(..,NA,..)) {was "color NA ..."}
Paul Murrell