pbreheny / visreg

Visualization of regression functions
http://pbreheny.github.io/visreg/
61 stars 18 forks source link

with plot.type = "Plot3D"? #84

Closed HaoLi111 closed 3 years ago

HaoLi111 commented 4 years ago

Can we have an option to use Plot3D https://cran.r-project.org/web/packages/plot3D/vignettes/plot3D.pdf to create visualization for 2d -> 1d functions? it seems to be easier to use than most other packages. (especially if we can use add = TRUE, so that the actual data points can be plotted along with the regression surface?)

pbreheny commented 4 years ago

You mean, you want to do something like this?

fit <- lm(Ozone ~ Solar.R + Wind + Temp + I(Wind^2) + I(Temp^2) +
            I(Wind*Temp)+I(Wind*Temp^2) + I(Temp*Wind^2) + I(Temp^2*Wind^2),
          data=airquality)
v <- visreg::visreg2d(fit, x="Wind", y="Temp", plot=FALSE)
plot3D::persp3D(v$x, v$y, v$z)

But have visreg provide a wrapper so that you can combine the last two lines of code into a single line?

HaoLi111 commented 4 years ago

This is great! And can we also have a parameter that add things onto a 3D plot with

persp3Drgl()

and perhaps having

add = True

or

add = False

to enable further customizations? (for example, we can see how the real data points compare to the surface)

pbreheny commented 3 years ago

I'm going to close this issue, at least for now. If there is substantial demand for this, I am certainly willing to add an option for persp3D. It just seems to me that it is (a) pretty trivial to just do it yourself and (b) directly calling persp3D will allow much more control over all the options, which is what you seem to be after, trying to customize the plot by displaying observed data points, etc.