Reputation: 19833
I plot a 3d plot in R using persp
. I have two questions with respect to this:
Want to verify that I understand the docs correctly. persp
will take the valuex from x
and y
, then depending on the index of each value in those vectors, say (i,j)
corresponding to the current element in x
and y
, (x[i],y[j])
, it will pluck out zfit[i,j]
and plot (x[i],y[j],zfit[i,j])
. Is this correct?
This does not produce the numbers on the actual axis but arrows in the increasing direction. How do I make numbers appear?
Example:
set.seed(1)
x = 1:10
y = rnorm(10)
z = x + y^2
g = expand.grid(list(x=seq(from=min(x), to=max(x), length.out=100),y=seq(from=min(y), to=max(y), length.out=100)))
mdl = loess(z ~ x+ y)
zfit = predict(mdl, newdata=g)
persp(x = seq(from=min(x), to=max(x), length.out=100), y = seq(from=min(y), to=max(y), length.out=100), z= zfit)
Upvotes: 0
Views: 573
Reputation: 1366
Upvotes: 1