[R] Response surface plot
Cleber Borges
klebyn at yahoo.com.br
Wed May 13 02:25:42 CEST 2009
hello,
I have an code for similar plot in 2D.
HTH
Cleber Borges
------------------------------------------------------
#########################################################
#########################################################
#########################################################
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) )
}
### EXAMPLE
ternary_func <- function(x1, x2) {
x3=1-x1-x2
-100*x1 + 0*x2 + 100*x3 + 200*x1*x2
}
zmat1 <- trimage(ternary_func)
windows(w=4.5, h=4.5, restoreConsole = TRUE )
par(mar=c(5,5,5,5), pty='s', xaxt='n', yaxt='n', bty='n' )
image(z=zmat1, ylab='', xlab='' )
contour(z=zmat1, add=T, nlevels=10 )
### tips.: use tim.colors in package 'fields'
library(fields)
windows(w=4.5, h=4.5, restoreConsole = TRUE )
par(mar=c(5,5,5,5), pty='s', xaxt='n', yaxt='n', bty='n' )
image(z=zmat1, ylab='', xlab='', col=tim.colors(256) )
contour(z=zmat1, add=T, nlevels=10 )
#########################################################
#########################################################
#########################################################
------------------------------------------------------
Tim Carnus escreveu:
> Dear List,
> I am trying to plot a similar graph to attached from minitab manual in R.
> I have a response Y and three components which systematically vary in their
> proportions. I have found in R methods/packages to plot ternary plots (eg.
> plotrix) but nothing which can extend it to response surface in 3-D.
> Any help appreciated,
> Tim Carnus
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list