Ryan Fasching
Ryan Fasching

Reputation: 541

Make a 3-d plot using rgl in R?

I have a matrix z that spits out a 20 by 20 matrix with with values starting at -9 to -739. I downloaded rgl but I can't figure out how to use it with my matrix: z[i, j]

Upvotes: 3

Views: 107

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226781

How about:

set.seed(101)
z <- matrix(sample(-739:-9,replace=TRUE,400),20)
library(rgl)
persp3d(z,col="gray")

enter image description here

Upvotes: 3

Related Questions