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
4
  • 3
    provide reproducible example (stackoverflow.com/questions/5963269/…)
    – jon
    Commented May 13, 2014 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) Commented May 13, 2014 at 13:01
  • I have updated my post, @StephanKolassa thanks, I think you have answered my question
    – Kaja
    Commented May 13, 2014 at 13:04
  • Read the help for persp? Why did you write what you wrote? Were you guessing?
    – Spacedman
    Commented May 13, 2014 at 13:05

1 Answer 1

1

Thanks for the reproducible example.

persp(z=k)

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.