Re: [R] custom tick labels on image

From: Pieter Provoost <>
Date: Fri 07 Jul 2006 - 03:20:25 EST

Prof Brian Ripley schreef:
> 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()).)

Thanks, this worked fine. One additional question: how can I rotate the labels so they all can be displayed? Srt doesn't seem to work.

x <- (1:nrow(data))
y <- (1:ncol(data))
image(y, x, t(data), col = heat.colors(20), 
axis(3, at = 1:ncol(data), labels=colnames(data),srt=45,tick=FALSE) axis(2, at = 1:nrow(data), labels=rownames(data),srt=45,tick=FALSE) mailing list PLEASE do read the posting guide! Received on Fri Jul 07 03:27:20 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 07 Jul 2006 - 04:15:34 EST.

Mailing list information is available at Please read the posting guide before posting to the list.