Dear R-helpers,

I would like to create a three dimensional plot with the following data set:

X1    X2    Y
3    4      22.654
4    3      20.054
2    2      17.601
1    1      35.868
4    2      NA
2    1      18.703
3    2      15.533
4    4      19.018
8    4      23.789
2    3      21.234
3    4      18.407
3    2      24.549
3    3      16.992
2    4      19.495

The two explanatory variables are continuous. The command in R to get a nice 
plot is simple
and there are at  least two possibilities. E.g.:

require(visreg) 
P1<-lm(Y~X1*X2)
visreg2d(P1, "X1", "X2", plot.type = "persp")

require(rsm)
persp(P1, X2 ~ X1, zlab = "Y")

The problem is, that both commands return extrapolated plots, that show values 
for y = -20 when X1 = 8 and X2 = 1.
But those values actually do not exist. Now I would like to cut the created 
surface plane to those values that are in 
the table. That means, something like: z = c(10,35) would be a good start (and 
it works, but it looks really ugly and I would
like to have the line smooth). 
It would even be better, if I could represent the plot only in those areas for 
X1 and X2 that are actually in the table. But I have no idea what the correct 
commands are, so that the plot does look nice afterwards.

Thank you very much for your help!

A great new years eve to everybody and a wonderful year 2014.

Greetings,
Anna


                                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to