0

I have an 32x32 matrix called I and would like to try to plot it. I.e. the two axes should range from 1 to 32 each and on the z-axis I would like to see the different values. If it is possible to connect those points even better, not the most important part right now.

I've tried it using the package "library(emdbook)", however the following line

curve3d(I[x,y], xlim=c(1:N), ylim=c(1:N))

However, it delivers me the error "Error in I[x, y] : object of type 'closure' is not subsettable".

I'm happy for any suggestion on what to change :)

Thank you!

Prasad
  • 1,562
  • 5
  • 26
  • 40
nicole
  • 1
  • Please provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) when you're seeking for assistance. – Adam Quek Apr 20 '17 at 02:50
  • how about a heat map? I'm thinking that if you want a 3D, then you must have a sort of matrix data for each axis? – din Apr 20 '17 at 02:51

1 Answers1

1

You can produce a surface plot e.g. by using persp:

## Example data:
x <- (1:32)/32
y <- (1:32)/32
model <- function (a, b){
    1 - (a-0.5)^2 - (b-0.5)^2
} 
z <- outer(x, y, model)

## Simple surface plot:
persp(x,y,z,box = TRUE, theta = -40, phi = 20)

simple surface plot

But as @din stated, a heatmap might be more suitable:

## Simple heatmap:
image(t(z))

simple heatmap

ikop
  • 1,760
  • 1
  • 12
  • 24