[R] vis.gam() contour plots

David Winsemius
Tue, 13 Oct 2009 02:20:34 -0000

On Oct 12, 2009, at 8:20 PM, Jason Gasper wrote:

> Greetings,
>
> I have what I hope is a simple question.  I would like to change my
> contour interval on the vis.gam( plot.type="contour")  in the
mgcv
> package.  Is this a situation where I need to modify the function or
> is there a default value I can change?

Looking at the help page, it seemed pretty likely that passing the
appropriate parameter to contour ought to work. Looking at the help
page for contour you should see nlevels, andrunning a contour example
is amenable to adding nlevels:

library(mgcv)
set.seed(0)
n<-200;sig2<-4
x0 <- runif(n, 0, 1);x1 <- runif(n, 0, 1)
x2 <- runif(n, 0, 1)
y<-x0^2+x1*x2 +runif(n,-0.3,0.3)
g<-gam(y~s(x0,x1,x2))
# display the prediction surface in x0, x1 ....
# contour examples.... vis.gam(g,
view=c("x1","x2"),plot.type="contour",color="heat",
nlevels=20)
Warning messages:
1: In plot.window(...) : "nlevels" is not a graphical parameter
2: In plot.xy(xy, type, ...) : "nlevels" is not a graphical parameter
3: In axis(side = side, at = at, labels = labels, ...) :
   "nlevels" is not a graphical parameter
4: In axis(side = side, at = at, labels = labels, ...) :
   "nlevels" is not a graphical parameter
5: In box(...) : "nlevels" is not a graphical parameter
6: In title(...) : "nlevels" is not a graphical parameter

# This does result in warnings that do not seem correct (since nlevels
is listed as a graphics parameter in the help page of contour) but the
desired effect seems to be occurring. I have seen such warnings many
times before an have learned to ignore them. Whether that is the
correct posture to assume, I am not sure.
> Thanks

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT