[R] persp() problem

Economics Guy economics.guy at gmail.com
Mon Sep 10 21:48:31 CEST 2007


I am having some trouble getting the persp() package to change the x
and y axis on a 3d plot. It defaults to the [0,1] interval and when I
try to change it I get errors.

Example:

This works:
------------
D <- c(1,2,3,4,5,6,7,8,9,10)
M <- c(11,12,13,14,15,16,17,18,19,20)

DM <- cbind(D,M)

persp(DM, theta = 40, phi = 30, expand = 0.5, col = "lightblue",
      ltheta = 120, shade = 0.75, ticktype = "detailed",
      xlab = "X", ylab = "Y", zlab = "Z")
---------------------


But I want the axis to count 1 by ones. So I try:
-----------------
D <- c(1,2,3,4,5,6,7,8,9,10)
M <- c(11,12,13,14,15,16,17,18,19,20)

DM <- cbind(D,M)

x <- 1*0:10
y <- 1*0:20
persp(x,y,DM, theta = 40, phi = 30, expand = 0.5, col = "lightblue",
      ltheta = 120, shade = 0.75, ticktype = "detailed",
      xlab = "X", ylab = "Y", zlab = "Z")
-------------------------

I get:

Error in persp(x, y, z, xlim, ylim, zlim, theta, phi, r, d, scale,
expand,  : invalid 'z' argument

but the z was fine in the first version so I am not sure what the deal is.

Any ideas?

-Econ Guy



More information about the R-help mailing list