[R] "Over-coloring" facets on persp() plot
Duncan Murdoch
murdoch at stats.uwo.ca
Sun Nov 22 13:07:17 CET 2009
On 22/11/2009 1:07 AM, Marc Chiarini (Tufts) wrote:
> Dear R Community:
>
> Recently, I have managed to plot some really useful graphs of my
> research data using persp(). I have even figured out how to overplot
> rectangular regions (corresponding to submatrices) with a different
> color. This is accomplished by using par(new=T). I am now searching
> for a way to "highlight" a set of (possibly non-contiguous) facets with
> a specific color, e.g., the facet between each set of four points whose
> values are all above a certain threshold. An example would be coloring
> the raised corners of the classic sombrero (found in example(persp))
> differently from the rest of the sombrero. I feel like the last example
> in persp() is pointing me in the right direction, but I'm not quite
> getting it. Any help is much appreciated.
Think of the facets as an nx-1 by ny-1 matrix. Pass the col arg by
creating a matrix of this shape. (A vector version of the data in the
matrix would also be good enough.)
If you pass something shorter, it will be recycled to that length.
You could also use persp3d from the rgl package, but an important
difference is that it colours all nx by ny vertices, and interpolates
colours on the facets. So you can't use the same colour matrix as in persp.
Duncan Murdoch
More information about the R-help
mailing list