[R] Matrix 3d plot

David Winsemius dwinsemius at comcast.net
Tue Jul 5 19:55:23 CEST 2011


On Jul 5, 2011, at 1:36 PM, петрович wrote:

> I have a problem with a 3d plot, suppose we have a matrix like this:
>
>                   v1        v2       v3      v4
> jan-2010     0.5     0.25    0.25    0.3
> feb-2010     0.35   0.12   0.12    0.4
> mar-2010    0.15    0.25    0.25  0.1
>
> and i want to plot this matrix in 3d plot where x-axis is the first
> column of the matrix above, y - axis is the first row of the matrix
> above and the z-axis is the numbers corresponding, so
> z(jan-2010,v3)=0.25
>
> I was trying with persp()

But you didn't show your code.

> but i see that in this function z is a
> vector

That is not how I read help(persp).

> but in my case is a matrix,

Assuming the matrix is named "z", what happens with :

persp(z=z)


> so i receive an error message

And after reading the Posting Guide you will see that you are asked to  
report any error message verbatim.

And perhaps even more importantly it asks that you provide a  
reproducible version of your object with dump. It's even easier to use  
dput, but do include one or the other.

> I think this sound no so hard, but actually i couldn´t find a  
> function
> doing this, is there actually such a function?

There are many. But why not see if you can get persp to work?

> Christian
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list