[R] how to rotate a triangle image(ZMAT) ?

François Pinard pinard at iro.umontreal.ca
Tue Jun 27 21:45:33 CEST 2006


[Cleber N.Borges]

> how to align this Zmat (triangle image)  in X axis?  I would like that 
> the triangle's base become in the X axis and the triangle's height 
> become in the Y axis.  Is there some trick for make this?

I'm not fully sure of what is the base and the height of the triangle, 
but if I guess correctly, you may peek at "?image", the last paragraph 
of the "Details:" section, and also in the "Examples:" section, where it 
says "Need to transpose and flip matrix horizontally.".  Maybe you'll 
find some explanations or ideas in there.

> f <- function(x, y) {
>   z = 1-x-y
>   z[z < (-1e-15)] <- NA
    return(-100*x+0*y+100*z)
> }

> x = seq(1, 0, by = -0.01)
> y = seq(1, 0, by = -0.01)
> zmat = outer(x, y, f)

> image(zmat, col=terrain.colors(10))
> contour(zmat, add=T)

Another idea is to exchange "x, y" in the "outer" call, and maybe also 
use "rev()" on one of them.

-- 
François Pinard   http://pinard.progiciels-bpi.ca



More information about the R-help mailing list