简体   繁体   English

从R中的矩阵绘制3D图

[英]Drawing 3D plot from a matrix in r

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. 我在128行400列的exel文件中有一些数据,我正在将此Excel文件读入128X400的矩阵中。 Now I want to draw 3D Plott using presp in r. 现在,我想在R中使用presp绘制3D图。 Which parameters from this Matrix should be passed to persp? 应将此矩阵中的哪些参数传递给persp?

UPDATE UPDATE

I have this Matrix for example and I want to generate a 3D Plot, but I get an error: 例如,我有这个矩阵,我想生成一个3D图,但是出现错误:

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

Thanks for the reproducible example. 感谢您提供可复制的示例。

persp(z=k)

should do what you want. 应该做你想做的。 The help page ?persp may be helpful. 帮助页面?persp可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM