[R] Repeating grey scale in graph?

2005-02-16 Thread Sander Oom
Dear R users,
Could somebody tell me why the grey color ramp is repeated in this 
graph, eventhough the ramp values go from 0 to 1? I must be missing 
something obvious, but I can not see it!

z - 
c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.259835539,0.284571226,
0.038507288,0.094184749,0.140959431,0.180803984,0.215159105,0.245096084,0.271412845,
0.00775022,0.066198255,0.115433207,0.157494219,0.193836765,0.225569076,0.253518629,
-0.02820814,0.032958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392,
-0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.170630435,0.201956395,
-0.117878701,-0.050461393,0.005991829,0.054672666,0.097103088,0.134398711,0.167423957)

x - c(0,1,2,3,4,5)
y - c(50, 100, 150, 200, 250, 300, 350)
z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE)
#persp(x, y, z, theta = 30, phi = 30, expand = 0.5,
#  box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot)
hgt - (z - min(z))/ (max(z) - min(z))
z
hgt
cols - grey(hgt)
persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5,
  box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot)
Thanks,
Sander.
 version
 _
platform i386-pc-mingw32
arch i386
os   mingw32
system   i386, mingw32
status
major2
minor0.1
year 2004
month11
day  15
language R

--
-
Dr. Sander P. Oom
Animal, Plant and Environmental Sciences
University of the Witwatersrand
Private Bag 3
Wits 2050
South Africa
Tel (work)  +27 (0)11 717 64 04
Tel (home)  +27 (0)18 297 44 51
Fax +27 (0)18 299 24 64
Email   [EMAIL PROTECTED]
Web www.oomvanlieshout.net/sander
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Repeating grey scale in graph?

2005-02-16 Thread Uwe Ligges
Sander Oom wrote:
Dear R users,
Could somebody tell me why the grey color ramp is repeated in this 
graph, eventhough the ramp values go from 0 to 1? I must be missing 
something obvious, but I can not see it!
You missed to read the ehlp page ?persp:
col: the color(s) of the surface facets. Transparent colours are 
ignored. This is recycled to the (nx-1)(ny-1) facets.

Attention: (nx-1)x(ny-1) facets, but not nx x ny 
Uwe Ligges

z - 
c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.259835539,0.284571226, 

0.038507288,0.094184749,0.140959431,0.180803984,0.215159105,0.245096084,0.271412845, 

0.00775022,0.066198255,0.115433207,0.157494219,0.193836765,0.225569076,0.253518629, 

-0.02820814,0.032958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392, 

-0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.170630435,0.201956395, 

-0.117878701,-0.050461393,0.005991829,0.054672666,0.097103088,0.134398711,0.167423957) 

x - c(0,1,2,3,4,5)
y - c(50, 100, 150, 200, 250, 300, 350)
z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE)
#persp(x, y, z, theta = 30, phi = 30, expand = 0.5,
#  box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot)
hgt - (z - min(z))/ (max(z) - min(z))
z
hgt
cols - grey(hgt)
persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5,
  box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot)
Thanks,
Sander.
  version
 _
platform i386-pc-mingw32
arch i386
os   mingw32
system   i386, mingw32
status
major2
minor0.1
year 2004
month11
day  15
language R
 

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Repeating grey scale in graph?

2005-02-16 Thread Peter Dalgaard
Sander Oom [EMAIL PROTECTED] writes:

 Dear R users,
 
 Could somebody tell me why the grey color ramp is repeated in this
 graph, eventhough the ramp values go from 0 to 1? I must be missing
 something obvious, but I can not see it!
 
 z -
 c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.259835539,0.284571226,
 0.038507288,0.094184749,0.140959431,0.180803984,0.215159105,0.245096084,0.271412845,
 0.00775022,0.066198255,0.115433207,0.157494219,0.193836765,0.225569076,0.253518629,
 -0.02820814,0.032958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392,
 -0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.170630435,0.201956395,
 -0.117878701,-0.050461393,0.005991829,0.054672666,0.097103088,0.134398711,0.167423957)
 
 x - c(0,1,2,3,4,5)
 y - c(50, 100, 150, 200, 250, 300, 350)
 z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE)
 
 #persp(x, y, z, theta = 30, phi = 30, expand = 0.5,
 #  box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot)
 
 hgt - (z - min(z))/ (max(z) - min(z))
 z
 hgt
 cols - grey(hgt)
 persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5,
box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot)
 

You have 30 facets and 42 colour values. Try it with

cols - grey(hgt[-1,-1])


-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Repeating grey scale in graph?

2005-02-16 Thread Sander Oom
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?

Anyway it works,
Sander.
Peter Dalgaard wrote:
Sander Oom [EMAIL PROTECTED] writes:

Dear R users,
Could somebody tell me why the grey color ramp is repeated in this
graph, eventhough the ramp values go from 0 to 1? I must be missing
something obvious, but I can not see it!
z -
c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.259835539,0.284571226,
0.038507288,0.094184749,0.140959431,0.180803984,0.215159105,0.245096084,0.271412845,
0.00775022,0.066198255,0.115433207,0.157494219,0.193836765,0.225569076,0.253518629,
-0.02820814,0.032958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392,
-0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.170630435,0.201956395,
-0.117878701,-0.050461393,0.005991829,0.054672666,0.097103088,0.134398711,0.167423957)
x - c(0,1,2,3,4,5)
y - c(50, 100, 150, 200, 250, 300, 350)
z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE)
#persp(x, y, z, theta = 30, phi = 30, expand = 0.5,
#  box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot)
hgt - (z - min(z))/ (max(z) - min(z))
z
hgt
cols - grey(hgt)
persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5,
  box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot)

You have 30 facets and 42 colour values. Try it with
cols - grey(hgt[-1,-1])

--
-
Dr. Sander P. Oom
Animal, Plant and Environmental Sciences
University of the Witwatersrand
Private Bag 3
Wits 2050
South Africa
Tel (work)  +27 (0)11 717 64 04
Tel (home)  +27 (0)18 297 44 51
Fax +27 (0)18 299 24 64
Email   [EMAIL PROTECTED]
Web www.oomvanlieshout.net/sander
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Repeating grey scale in graph?

2005-02-16 Thread Achim Zeileis
On Wed, 16 Feb 2005 15:44:00 +0200 Sander Oom 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?

It does! 
cols is a vector of length 42 and only the first 30 are used. Try to
use your persp call below with col = cols and col = cols[1:30].
Z

 Anyway it works,
 
 Sander.
 
 
 Peter Dalgaard wrote:
  Sander Oom [EMAIL PROTECTED] writes:
  
  
 Dear R users,
 
 Could somebody tell me why the grey color ramp is repeated in this
 graph, eventhough the ramp values go from 0 to 1? I must be missing
 something obvious, but I can not see it!
 
 z -
 c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.2598
 35539,0.284571226,0.038507288,0.094184749,0.140959431,0.180803984,0
 .215159105,0.245096084,0.271412845,0.00775022,0.066198255,0.1154332
 07,0.157494219,0.193836765,0.225569076,0.253518629,-0.02820814,0.03
 2958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392,
 -0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.1706
 30435,0.201956395,-0.117878701,-0.050461393,0.005991829,0.054672666
 ,0.097103088,0.134398711,0.167423957)
 x - c(0,1,2,3,4,5)
 y - c(50, 100, 150, 200, 250, 300, 350)
 z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE)
 
 #persp(x, y, z, theta = 30, phi = 30, expand = 0.5,
 #  box= TRUE, axes= TRUE, ticktype = detailed, main=Title of
 plot)
 hgt - (z - min(z))/ (max(z) - min(z))
 z
 hgt
 cols - grey(hgt)
 persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5,
box= TRUE, axes= TRUE, ticktype = detailed, main=Title of
 plot)
  
  
  You have 30 facets and 42 colour values. Try it with
  
  cols - grey(hgt[-1,-1])
  
  
 
 -- 
 -
 Dr. Sander P. Oom
 Animal, Plant and Environmental Sciences
 University of the Witwatersrand
 Private Bag 3
 Wits 2050
 South Africa
 
 Tel (work)  +27 (0)11 717 64 04
 Tel (home)  +27 (0)18 297 44 51
 Fax +27 (0)18 299 24 64
 
 Email   [EMAIL PROTECTED]
 Web www.oomvanlieshout.net/sander
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Repeating grey scale in graph?

2005-02-16 Thread Uwe Ligges
Sander Oom 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?
Indeed, it ignores them in your case, but since each row of your matrix 
there is one too much this one is moved to the next row, 2 from row two 
to three, 3 from three to four,  and the last nx+ny-1 are omitted.

Uwe Ligges

Anyway it works,
Sander.
Peter Dalgaard wrote:
Sander Oom [EMAIL PROTECTED] writes:

Dear R users,
Could somebody tell me why the grey color ramp is repeated in this
graph, eventhough the ramp values go from 0 to 1? I must be missing
something obvious, but I can not see it!
z -
c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.259835539,0.284571226, 

0.038507288,0.094184749,0.140959431,0.180803984,0.215159105,0.245096084,0.271412845, 

0.00775022,0.066198255,0.115433207,0.157494219,0.193836765,0.225569076,0.253518629, 

-0.02820814,0.032958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392, 

-0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.170630435,0.201956395, 

-0.117878701,-0.050461393,0.005991829,0.054672666,0.097103088,0.134398711,0.167423957) 

x - c(0,1,2,3,4,5)
y - c(50, 100, 150, 200, 250, 300, 350)
z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE)
#persp(x, y, z, theta = 30, phi = 30, expand = 0.5,
#  box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot)
hgt - (z - min(z))/ (max(z) - min(z))
z
hgt
cols - grey(hgt)
persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5,
  box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot)

You have 30 facets and 42 colour values. Try it with
cols - grey(hgt[-1,-1])


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Repeating grey scale in graph?

2005-02-16 Thread Peter Dalgaard
Achim Zeileis [EMAIL PROTECTED] writes:

  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?
 
 It does! 
 cols is a vector of length 42 and only the first 30 are used. Try to
 use your persp call below with col = cols and col = cols[1:30].
 Z

Just to rub it in, consider

 M
 [,1] [,2] [,3] [,4] [,5]
[1,]23456
[2,]34567
[3,]45678
[4,]56789
[5,]6789   10
 M2 - matrix(M[1:16],4,4)
 M2
 [,1] [,2] [,3] [,4]
[1,]2666
[2,]3377
[3,]4448
[4,]5555


-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Repeating grey scale in graph?

2005-02-16 Thread Duncan Murdoch
On Wed, 16 Feb 2005 15:44:00 +0200, Sander Oom
[EMAIL PROTECTED] wrote :

Thanks Peter!

Of course I only have (nx-1)(ny-1) facets in a x*y plot!

The help page line:
...
colthe 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,]1111111
[2,]2222222
[3,]3333333
[4,]4444444
[5,]5555555
[6,]6666666
 matrix(rownum, 5, 6)
 [,1] [,2] [,3] [,4] [,5] [,6]
[1,]165432
[2,]216543
[3,]321654
[4,]432165
[5,]543216
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

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Repeating grey scale in graph?

2005-02-16 Thread Sander Oom
Aaaah...the inner workings of R! Now I also see why the colours are not 
only repeated, but also 'wrongly' allocated to the facets! Very clear 
example!

Indeed a warning or error would have been more helpful!
Cheers,
Sander.
PS: I hope that after all this, I can still convince the creator of the 
original data that it is a good idea to plot his graphs in R instead of 
excel.  ;-)

Duncan Murdoch wrote:
On Wed, 16 Feb 2005 15:44:00 +0200, Sander Oom
[EMAIL PROTECTED] 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,]1111111
[2,]2222222
[3,]3333333
[4,]4444444
[5,]5555555
[6,]6666666
 

matrix(rownum, 5, 6)
   

[,1] [,2] [,3] [,4] [,5] [,6]
[1,]165432
[2,]216543
[3,]321654
[4,]432165
[5,]543216
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
 

--
-
Dr. Sander P. Oom
Animal, Plant and Environmental Sciences
University of the Witwatersrand
Private Bag 3
Wits 2050
South Africa
Tel (work)  +27 (0)11 717 64 04
Tel (home)  +27 (0)18 297 44 51
Fax +27 (0)18 299 24 64
Email   [EMAIL PROTECTED]
Web www.oomvanlieshout.net/sander
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html