Hello R users...
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?
Thanks.
Cleber
######################## my test and try
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)
[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)] <- NAreturn(-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
I thank Fran?ois Pinard for your attention
one solution, but
very dirty
very ugly
and ~ 30% of calculations cut loose!
if somebody can give a tip, I thank...
Cleber
############
f <- function(x,y){
z=1-x-y
z[ z < (-1e-15) ] <- NA
return( -100*x + 0*y + 100*z )
}
x = y = seq( 1, 0, by = -0.01 )
z = outer(x,y,f)
t1 = length(x)
aux = numeric(0)
im = numeric(0)
for( i in seq( 1, t1, by = 2 ) ){
idx = seq( i*t1, t1**2, by = t1 ) - (0:(t1 - i))
im = c(im, aux, z[idx], aux )
aux = c(aux, NA)
}
im = matrix(im,nr=t1)
image(im, col=terrain.colors(256))
contour(im, add=T)
Cleber N.Borges wrote:> Hello R users... > > 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? >How about: image(zmat,col=terrain.colors(10),xlim=c(1,0),ylim=c(1,0)) Jim