0

I am interested in generating a series of simple 3d scatterplots which include regression planes without interactions using the scatterplot3d function in R. The following code generates almost what I am after with one problem- in many cases the regression plane extends outside of the bounding box (e.g. in this case, the corner nearest x, y and z =0). I tried changing the axis limits to increase the box size, but this does not alter the axis ranges as specified (which, according to the package documentation is an unfixed bug). Is there a way to either 1) re-draw the box to include the entire plane or 2) shrink the plane to include only the portion within the box?

example data

bugs<-c(335.20,8.68,1.94,3.22,21.79,11.16,1618.00,108.76,250.59,400.81,233.86,15.05,274.62,419.21)
max_dq<-c(0.015,0.001,0.001,0.001,0.002,0.007,0.04,0.001,0.014,0.003,0.002,0.006,0.004,0.013)
since_dist<-c(21,58,5,1,1,19,42,33,22,300,240,79,327,42)

library(scatterplot3d)

3 d plot

reg_plt<-scatterplot3d(max_dq,since_dist,bugs,angle=50)

regression plane

reg_plt$plane3d(lm(bugs~max_dq+since_dist))

Community
  • 1
  • 1
drew_g
  • 1
  • 3
  • Does it have to be `scatterplot3d`? `rgl` may be an alternative for your problem: `library(rgl); fit <- lm(bugs ~ max_dq + since_dist); plot3d(max_dq, since_dist, bugs); planes3d(coef(fit)["max_dq"], coef(fit)["since_dist"], -1, coef(fit)["(Intercept)"], alpha=0.5)`. – lukeA Jan 10 '15 at 17:55
  • @lukeA: Thanks very much. I was able to generate a reasonable plot using rgl. – drew_g Jan 10 '15 at 20:04
  • If anyone can answer my question regarding scatterplot3d, however, I would still be most interested. – drew_g Jan 10 '15 at 20:05

0 Answers0