[R] Plotting Two Surfaces in one plot with wireframe() using groups=

David Winsemius dwinsemius at comcast.net
Thu Jul 16 15:05:40 CEST 2009


There is a worked example of exactly what you are trying to do on the  
wireframe/cloud help page. Thinking incorrectly (and foolishly as it  
turned out) that this was a reproducible example. I tried your code.    
I then tried the help page code. If reviewing the help page is  
ineffective, then look carefully at T and (at the very least post) the  
results of:

str(T)

-- 
David


On Jul 16, 2009, at 6:41 AM, Lars Bergemann wrote:

>
> Hi. I tried the following:
>
> F<-function(x,y,b1,b2,b3) b1/(1+b2*(x+b3*y));
>
> t<-data.frame(ExM=c(T$ExM, F(T$S1,T$S2,0.2,0.2,51.28205)),

# This will create 2-ples which I am not sure wireframe is designed to  
handle. And why would you want T$ExM and F(S1,S2) together anyway?

>  S1=rep(T$S1,2), S2=rep(T$S2,2), gr=c(rep(1,length(T$ExM)),  
> rep(2,length(T$ExM))));

Perhaps an appropriate use of expand.grid() would be a safer approach  
prior to this step.

>
> library(lattice);
>
> wireframe(ExM ~ S1 * S2, data = t, groups=gr);
>
>
> where T is da dataframe like T<-data.frame(S1=...,S2=...,ExM=...)
>
> But the resulting response surface plot is mixed up, ie it is not  
> two seprate surfaces as it should be. I know that as I have plotted  
> them both seperately as well.
>
> Can anyone see what I am doing wrong


>
> Thanks!
>
> Lars
>

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list