[R] image axes

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Oct 8 19:46:29 CEST 2002

Roger Koenker wrote:
> I'm plotting matrices with image() and would like the axes to reflect
> the conventional view that the upper left corner of the plot is (1,1).
> But image seems to think that the lower left corner is (1,1).  Can
> someone suggest a way of persuading it to think otherwise.  In effect,
> I just want the y axis to run from from 1 to n downwards, not upwards.
> I thought that something like axes=FALSE in image and
>         axis(2,rev(pretty(1:n)))
> would do this, but the rev() effect gets lost for reasons I'm not too
> clear about.  Thanks for any suggestions...

Reason: you specify 'at', i.e. where the tick marks are plotted, and
that's the same positions as before.
You have to specify the labels addtionally. So the following should do
the trick:

 axis(2, at = pretty(1:n), labels = rev(pretty(1:n)))

Uwe Ligges
r-help 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-help-request at stat.math.ethz.ch

More information about the R-help mailing list