Tuesday 15 April 2014

r - 3D surface plot from 2D matrix -


Using a 2D matrix in R, how can I create a plot of a 3D surface, where column = x, rows = y and

Value is high in z?

In the example below, the x values ​​will be 1: 5, the y values ​​will be 1: 5, and the numbers represent the elevations / z.

  & gt; M & lt; -matrix (rnorm (25), nrow = 5, ncol = 5) & gt; I [[1] [, 2] [, 3] [, 4] [, 5] [1,] -1.49 5513045 0.8000040 -1.149 961 1.65661138 0.8140510 [2,] -1.150018195 -0.7582933 0.8306922 0.16026908 0.3913198 [3, ] -0.85260 9 406 0.5525621 0.3585986 -0.45054768 -1.2259927 [4,] -0.001926297 -0.5857351 2.1518281 0.03192463 0.2065039 [5,] -1.641128610 0.4333973 -1.0616628 -0.92143426 -0.9598991    

you should start the package rgl ...

  is required (RGL ) # Open renderer open3d () #top surface rgl.surface (1:10, 1:10, runif (100)) #png rgl.snapshot ("sample.png", fmt = "png", top = TRUE) Export   

Enter image details here < / P>

No comments:

Post a Comment