[R] Repeating grey scale in graph?
Duncan Murdoch
murdoch at stats.uwo.ca
Wed Feb 16 16:28:58 CET 2005
On Wed, 16 Feb 2005 15:44:00 +0200, Sander Oom
<slist at oomvanlieshout.net> wrote :
>Thanks Peter!
>
>Of course I only have (nx-1)(ny-1) facets in a x*y plot!
>
>The help page line:
>...
>col the color(s) of the surface facets. Transparent colours are
>ignored. This is recycled to the (nx-1)(ny-1) facets.
>...
>just did not ring a bell.
>
>In fact, it is still not clear to me why it recycles the ramp even
>though it has a surplus of colours (grey levels)! Why not just ignore
>the surplus colours?
Your z array is 6 by 7. Your cols will be mapped to a 5 by 6 array.
They don't look like an array, because the grey() function stripped
off the dimension attribute.
The problem is that if you pass the entries from a 6 by 7 array to
something that expects the entries from a 5 by 6 array, you get things
in the wrong order. You see the same effect here:
> rownum <- as.vector(row(matrix(NA, 6, 7)))
> matrix(rownum, 6, 7)
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,] 1 1 1 1 1 1 1
[2,] 2 2 2 2 2 2 2
[3,] 3 3 3 3 3 3 3
[4,] 4 4 4 4 4 4 4
[5,] 5 5 5 5 5 5 5
[6,] 6 6 6 6 6 6 6
> matrix(rownum, 5, 6)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 1 6 5 4 3 2
[2,] 2 1 6 5 4 3
[3,] 3 2 1 6 5 4
[4,] 4 3 2 1 6 5
[5,] 5 4 3 2 1 6
Warning message:
data length [42] is not a sub-multiple or multiple of the number of
rows [5] in matrix
except that in this case you get a warning about the wrong length;
persp doesn't give you the warning. Maybe it should?
Duncan Murdoch
More information about the R-help
mailing list