"contours" is not a graphical parameter when using persp() in rsm package

148 views Asked by At

I'm trying to implement a 3D plot in R using the rsm package's persp() function. I'd like to add contour lines to the base of the plot, for example like here: Draw a line after persp using rsm in R

The rsm documentation says this should be possible:

In persp, contour lines may be added via the contours argument. It may be a boolean or character value, or a list. If boolean and TRUE, default black contour lines are added to the bottom surface of the box

https://cran.r-project.org/web/packages/rsm/rsm.pdf

When I do this, I get a warning and no contours, although the 3D plot generates just fine: "Warning message: In persp.default(a, t, q, contours = ("top") : "contours" is not a graphical parameter

I was able to get this pattern working using code here: Is there a way to create a 3d plot with contours beneath the plot in R?

But it would be nice to know why the rsm package doesn't (appear to) work as advertised, unless I'm doing something wrong?

Here is my MWE:

library(rsm)

surface <- function(a, t){
  q <- (4*40)/(4*a^2 + 4*a*t^2 + t^4 + 4*40)
}

a <- seq(.00001, 5, length= 20)
t <- seq(.00001, 5, length= 20)
q <- outer(a, t, surface)

persp(a, t, q,
      contours=("top"))

persp(a, t, q,
      contours=T)

0

There are 0 answers