0

I have a some data in an exel file with 128 rows and 400 column.I am reading this Excel file into a Matrix with 128X400. Now I want to draw 3D Plott using presp in r. Which parameters from this Matrix should be passed to persp?

UPDATE

I have this Matrix for example and I want to generate a 3D Plot, but I get an error:

k<-c(1,2,3,4,5,6,7,8,9,10,11,12,62,25,2)
k<-matrix(k,nrow=3)
op <- par(bg = "white")
persp(ncol(k), nrow(k), k, theta = 30, phi = 30, expand = 0.5, col = "lightblue")

Error:

Error in persp.default(ncol(k), nrow(k), k, theta = 30, phi = 30, expand = 0.5,  : 
  invalid 'x' argument
Brian Diggs
  • 57,757
  • 13
  • 166
  • 188
Kaja
  • 2,962
  • 18
  • 63
  • 99
  • 3
    provide reproducible example (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – jon May 13 '14 at 12:58
  • 1
    From your description, you already have a matrix (make sure it really is a `matrix`, not a `data.frame`, by using `class()`). Just feed that into the `z` parameter of `persp()`: `persp(z=foo)` – Stephan Kolassa May 13 '14 at 13:01
  • I have updated my post, @StephanKolassa thanks, I think you have answered my question – Kaja May 13 '14 at 13:04
  • Read the help for persp? Why did you write what you wrote? Were you guessing? – Spacedman May 13 '14 at 13:05

1 Answers1

1

Thanks for the reproducible example.

persp(z=k)

should do what you want. The help page ?persp may be helpful.

Stephan Kolassa
  • 7,953
  • 2
  • 28
  • 48