[Rd] Strange behaviour of image (PR#510)

Prof Brian D Ripley ripley@stats.ox.ac.uk
Sat, 8 Apr 2000 09:42:37 +0100 (BST)


On Fri, 7 Apr 2000, Prof Brian Ripley wrote:

> 
> > Date: Fri, 7 Apr 2000 17:04:17 +0100 (BST)
> > From: Jonathan Rougier <J.C.Rougier@durham.ac.uk>
> > 
> > Hi Peter,
> > 
> > On 6 Apr 2000, Peter Dalgaard BSA wrote:
> > 
> > > J.C.Rougier@durham.ac.uk writes:
> > > 
> > > > The following commands
> > > > 
> > > > z <- matrix(seq(0, 1, len=1000))
> > > > image(z, 1, z, zlim=c(0, 1), col=gray(1:10/10))
> > > > 
> > > > appear to violate the image functionality as described on the
> > > > help page.  As I understand it, by specifying a zlim of c(0, 1)
> > > > and a colour vector of length 10, the colours should correspond
> > > > to the intervals (0, 0.1), (0.1, 0.2), ..., (0.9, 1.0), this
> > > > being 10 equally-spaced intervals on (0, 1).  It is clear from
> > > > the image that this has not occurred.  In fact the intervals are
> > > > apparently (0, 1/18), (1/18, 3/18), ..., (15/18, 17/18), (17/18,
> > > > 1).  Have I misunderstood something?
> > > 
> > > I don't see that anything else is being promised...
> > > 
> > > If someone actually thought about this, then the choice might be
> > > related to the behavior at peaks and troughs. (since a circle with
> > > radius r looks wide compared to the region between two circles with
> > > diameter n*r and (n+1)*r)
> > 
> > I'm not quite sure I follow.  My feeling is that the displayed behaviour
> > of image is unreasonable, and, I hazard, not what most people who use
> > image expect.  I think the default behaviour of image should be to give
> > colour bands of equal widths, and, if I may append to the wish list, I
> > woud like to be able to specify a "breaks" argument to have unequal widths
> > should I so choose.
> 
> I side with Jonathan.
> 
> (1) The prototype does as JCR describes: given 64 colours it allocates
> 1/64th of the space to each.
> 
> (2) Setting the break points seems a good idea to me (but can always be
> faked by a non-linear monotonic transformation of z, as I have done
> before now).
> 
> I suggest we do add a `breaks' arg and that we do change the default
> at the level of the R code, perhaps with an oldstyle parameter.
> OK?

Now done for R-devel. The new version computes the indices into the colour
table in the R code so is much easier to customize.

help(image) did say

    zlim: the minimum and maximum `z' values for which colors will be
          plotted.  Each of the given colors will be used to color an
          equispaced interval of this range.

and what happened was that the midpoints of the colour grid covered the
range, so the lowest and highest z values which were plotted were smaller
and larger than as specified here.  I've altered the help file for 1.0.1.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._