[R] image axes

Roger Koenker roger at ysidro.econ.uiuc.edu
Tue Oct 8 20:05:00 CEST 2002


Thanks Uwe, that's not quite what I wanted, but it was an excellent hint.
For the record, the suggestion works fine if pretty is symmetrically
spaced on the axis, but otherwise it isn't quite the right thing.  But
this is easily fixed by playing with the image x,y arguments as follows:

image(x=1:p,y=-(n:1),t(z),axes=FALSE,
        col=c("white","gray"),xlab="column",ylab="row")
axis(1,pretty(1:p))
axis(2,pretty(-(n:1)),labels=rev(pretty(1:n)))


url:	http://www.econ.uiuc.edu		Roger Koenker
email	roger at ysidro.econ.uiuc.edu		Department of Economics
vox: 	217-333-4558				University of Illinois
fax:   	217-244-6678				Champaign, IL 61820

On Tue, 8 Oct 2002, Uwe Ligges wrote:

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