Skip to content
Back to formatted view

Raw Message

Message-ID: <3EDA2FA3.8020207@statistik.uni-dortmund.de>
Date: 2003-06-01T16:53:55Z
From: Uwe Ligges
Subject: persp & colors
In-Reply-To: <20030601163917.GA19993@pcf004.jinr.ru>

Timur Elzhov wrote:
> Dear R experts!
> 
> I use image() & persp() functions for color plotting z(x,y)-type
> graphics.  In image() colors correspond to z-values, that's what
> I want.   OTOH, in persp() the col option means:
> 
>      col: the color(s) of the surface facets.  Transparent colours are
>           ignored.  This is recycled to the (nx-1)(ny-1) facets.
> 
> but I'd like to persp()' colors behave like in image() function!
> 
> Could you help me to solve this problem?
> Thank you very much.
> 
> 
> --
> WBR,
> Timur.

That's not easy, because you have to redefine x, y and z values.

Simple example:

  x <- y <- 1:2
  z <- matrix(1:4, 2)
  image(x, y, z)    # OK, quite nice

but

  persp(x, y, z)

has only one facet. So the only way is to calculate the 9 values for x, 
y, and z to get the corners for the 4 facets in it.
That's easy for x and y, but can be impossible for z...

Uwe Ligges