Skip to content

3D Surface plot

1 message · Peter Ehlers

#
On 2010-04-30 13:35, abotaha wrote:
You're misunderstanding what scatterplot3d() does: it produces a
_point cloud_, not a surface. You probably want persp() or
wireframe() in pkg:lattice.

Try this:

  z1 <- matrix(z, 9, 9)
  persp(x, y, z1)

or

  library(lattice)
  g <- expand.grid(x = x, y = y)
  g$z <- z
  wireframe(z ~ x * y, data = g)

or, depending on your needs, you might want to fool around
with persp3d() in the rgl package (assuming that have installed it):

  library(rgl)
  persp3d(x, y, z1, col = 'skyblue')

  -Peter Ehlers