[R] custom tick labels on image

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jul 6 18:50:29 CEST 2006


On Thu, 6 Jul 2006, Pieter Provoost wrote:

> Hi,
>
> I'm trying to visualise a matrix using image(), and I would like to add
> the row and column names as tick labels. I tried adding an axis, but the
> problem is that this axis goes from 0 to 1 which results in labels being
> added starting at the far right end of the axis.
>
> image(t(data), col = terrain.colors(20), axes=FALSE)
> axis(3, at = 1:length(colnames(data)), labels=colnames(data))
>
> How can I do this better?

It is probably easiest to supply x and y when calling image, as in the 
final example on the help page.  (And BTW, ncol() gives the number of 
columns more readily than length(colnames()).)

-- 
Brian D. Ripley,                  ripley at 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list