[R] image weirdness
Bill Simpson
wsimpson at gcal.ac.uk
Thu May 6 14:49:09 CEST 1999
I am using R 63.0.
Now let's try this simple image plot.
Here is the data file:
============================
lag1 lag2 cif2d
1 1 11
1 2 12
1 3 13
2 1 21
2 2 22
2 3 23
3 1 31
3 2 32
3 3 33
====================
data<-read.table("~/r/rt/data/unif/junk.out",header=TRUE)
x<-unique(data$lag1)
y<-unique(data$lag2)
z<-matrix(data$cif2d,length(y),length(x))
At this point, see the z matrix:
> z
[,1] [,2] [,3]
[1,] 11 21 31
[2,] 12 22 32
[3,] 13 23 33
This is correct.
Now, the image plot should have cell values in this layout:
y
3 | 13 23 33
2 | 12 22 32
1 | 11 21 31
---------------------------
1 2 3 x
But when I do:
image(x,y,z, col=gray(0:19/19),xlab="Lag 1 (s)", ylab="Lag 2 (s)")
The resulting plot has the values
31 32 33
21 22 23
11 12 13
In other words it seems image() has reversed the x and y values.
So I do:
image(y,x,z, col=gray(0:19/19),xlab="Lag 1 (s)", ylab="Lag 2 (s)")
And the plot is exactly the same!!
What is going on, and how to fix? Thanks very much for any help.
(BTW, it seems that persp() works correctly in this example, assuming the
x axis is the one in the front of the drawn cube, y is the axis going
into the page, and z is the height)
Bill Simpson
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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