[R] Triangular filled contour plot

Cleber Borges klebyn at yahoo.com.br
Tue Feb 16 19:51:01 CET 2010


hello,
maybe this code can be useful for you.

cleber
-----------------------


trimage <- function(f){
x = y = seq( 1, 0, l=181 )
t1 = length(x)
im = aux = numeric(0)
for( i in seq( 1, t1, by = 2 ) ){

     #idx = seq( t1**2, i*t1, by = -t1 ) - ((t1 - i):0)

     idx = seq( i*t1, t1**2, by = t1 ) - (i-1)
     im = c(im, aux, idx, aux )
     aux = c(aux, NA)
     }
z =  outer(X=x, Y=y, FUN=f)
return( matrix(z[im],nr=t1) )
}


### for chemical mixtures
### restriction:   sum( x[i]==1 ) and  0 < x[i] < 1
### naive example
f <- function(x1,x2) { x3=1-x2-x1;  -100*x1 + 0*x2 + 100*x3 }

windows(w=4.5, h=4.5, restoreConsole = TRUE )
par(mar=c(0,0,0,0), pty='s', xaxt='n', yaxt='n', bty='n' )

trimat <- trimage( f )
image( trimat )
contour( trimat, add=T)









Em 16/2/2010 11:25, kajo escreveu:
> Hi all,
>
> I am working on a filled contour plot which shows a triangular matrix data
> set (as shown below). Is there a possibilty to draw a triangular filled
> contour in a equilateral triangle (like a ternary plot)?
>
> Thanks in advance
> Johannes
>
> http://n4.nabble.com/file/n1557386/Bild3.png
>    


-- 
O bom senso é a coisa do mundo mais bem distribuída:
Todos pensamos tê-lo em tal medida que até os mais difíceis
de contentar nas outras coisas não costumam desejar mais bom senso do que aquele que têm.
[René Descartes]



More information about the R-help mailing list