Is there a way to draw 3d plot?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Is there a way to draw 3d plot?

LosemindL
Hi all,

I have a 2D matrix, which has 100 rows, and 100 columns,

I have a 2D matrix, with 100 rows and 100 columns,

I want to display it using 3D plot, much like plot3d and mesh/surf functions
in matlab.

Specifically, in matlab, I just need to do the following:

--------
[X, Y]=meshgrid([0:0.01:0.99, 0:0.01:0.99]);
% Z is my 2D matrix,
surf(X, Y, Z);
--------

Note that X and Y are created so that I can associate physical meaning onto
the x and y axis of the 3D plot.

For example, my 100 rows represent 0, 0.01, 0.02, ... 0.99 here.

In Matlab I can also drag in the graphic window and see from different
visual angle and perspective of the 3D plot...

Are there similar functions in R that (1) show 3D plot; (2) let me
manipulate view angles easily?

Thanks a lot!

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there a way to draw 3d plot?

Uwe Ligges
Michael wrote:

> Hi all,
>
> I have a 2D matrix, which has 100 rows, and 100 columns,
>
> I have a 2D matrix, with 100 rows and 100 columns,
>
> I want to display it using 3D plot, much like plot3d and mesh/surf functions
> in matlab.
>
> Specifically, in matlab, I just need to do the following:
>
> --------
> [X, Y]=meshgrid([0:0.01:0.99, 0:0.01:0.99]);
> % Z is my 2D matrix,
> surf(X, Y, Z);
> --------
>
> Note that X and Y are created so that I can associate physical meaning onto
> the x and y axis of the 3D plot.
>
> For example, my 100 rows represent 0, 0.01, 0.02, ... 0.99 here.
>
> In Matlab I can also drag in the graphic window and see from different
> visual angle and perspective of the 3D plot...
>
> Are there similar functions in R that (1) show 3D plot; (2) let me
> manipulate view angles easily?

(1) See ?persp

(1) *and* (2): See package "rgl".

Uwe Ligges



> Thanks a lot!
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there a way to draw 3d plot?

LosemindL
On 5/26/06, Uwe Ligges <[hidden email]> wrote:

>
> Michael wrote:
>
> > Hi all,
> >
> > I have a 2D matrix, which has 100 rows, and 100 columns,
> >
> > I have a 2D matrix, with 100 rows and 100 columns,
> >
> > I want to display it using 3D plot, much like plot3d and mesh/surf
> functions
> > in matlab.
> >
> > Specifically, in matlab, I just need to do the following:
> >
> > --------
> > [X, Y]=meshgrid([0:0.01:0.99, 0:0.01:0.99]);
> > % Z is my 2D matrix,
> > surf(X, Y, Z);
> > --------
> >
> > Note that X and Y are created so that I can associate physical meaning
> onto
> > the x and y axis of the 3D plot.
> >
> > For example, my 100 rows represent 0, 0.01, 0.02, ... 0.99 here.
> >
> > In Matlab I can also drag in the graphic window and see from different
> > visual angle and perspective of the 3D plot...
> >
> > Are there similar functions in R that (1) show 3D plot; (2) let me
> > manipulate view angles easily?
>
> (1) See ?persp
>
> (1) *and* (2): See package "rgl".
>
> Uwe Ligges
>
>
>
> Thanks a lot,

But a glance at "rgl" seems requireing "shape", etc... and very
complicated...

Any easier approaches?

"persp" does not allow me to use mouse to rotate....

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there a way to draw 3d plot?

Antonio, Fabio Di Narzo
2006/5/26, Michael <[hidden email]>:

>
> On 5/26/06, Uwe Ligges <[hidden email]> wrote:
> >
> > Michael wrote:
> >
> > > Hi all,
> > >
> > > I have a 2D matrix, which has 100 rows, and 100 columns,
> > >
> > > I have a 2D matrix, with 100 rows and 100 columns,
> > >
> > > I want to display it using 3D plot, much like plot3d and mesh/surf
> > functions
> > > in matlab.
> > >
> > > Specifically, in matlab, I just need to do the following:
> > >
> > > --------
> > > [X, Y]=meshgrid([0:0.01:0.99, 0:0.01:0.99]);
> > > % Z is my 2D matrix,
> > > surf(X, Y, Z);
> > > --------
> > >
> > > Note that X and Y are created so that I can associate physical meaning
> > onto
> > > the x and y axis of the 3D plot.
> > >
> > > For example, my 100 rows represent 0, 0.01, 0.02, ... 0.99 here.
> > >
> > > In Matlab I can also drag in the graphic window and see from different
> > > visual angle and perspective of the 3D plot...
> > >
> > > Are there similar functions in R that (1) show 3D plot; (2) let me
> > > manipulate view angles easily?
> >
> > (1) See ?persp
> >
> > (1) *and* (2): See package "rgl".
> >
> > Uwe Ligges
> >
> >
> >
> > Thanks a lot,
>
> But a glance at "rgl" seems requireing "shape", etc... and very
> complicated...
>
> Any easier approaches?
>
> "persp" does not allow me to use mouse to rotate....
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>


Have you seen the example in 'rgl' man page?
It seems sufficient something like:
rgl.surface(x,y,z)

In that example, is also showed how to colorize the surface.

Antonio.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there a way to draw 3d plot?

Duncan Murdoch
On 5/26/2006 3:39 AM, Antonio, Fabio Di Narzo wrote:

> 2006/5/26, Michael <[hidden email]>:
>> On 5/26/06, Uwe Ligges <[hidden email]> wrote:
>>> Michael wrote:
>>>
>>>> Hi all,
>>>>
>>>> I have a 2D matrix, which has 100 rows, and 100 columns,
>>>>
>>>> I have a 2D matrix, with 100 rows and 100 columns,
>>>>
>>>> I want to display it using 3D plot, much like plot3d and mesh/surf
>>> functions
>>>> in matlab.
>>>>
>>>> Specifically, in matlab, I just need to do the following:
>>>>
>>>> --------
>>>> [X, Y]=meshgrid([0:0.01:0.99, 0:0.01:0.99]);
>>>> % Z is my 2D matrix,
>>>> surf(X, Y, Z);
>>>> --------
>>>>
>>>> Note that X and Y are created so that I can associate physical meaning
>>> onto
>>>> the x and y axis of the 3D plot.
>>>>
>>>> For example, my 100 rows represent 0, 0.01, 0.02, ... 0.99 here.
>>>>
>>>> In Matlab I can also drag in the graphic window and see from different
>>>> visual angle and perspective of the 3D plot...
>>>>
>>>> Are there similar functions in R that (1) show 3D plot; (2) let me
>>>> manipulate view angles easily?
>>> (1) See ?persp
>>>
>>> (1) *and* (2): See package "rgl".
>>>
>>> Uwe Ligges
>>>
>>>
>>>
>>> Thanks a lot,
>> But a glance at "rgl" seems requireing "shape", etc... and very
>> complicated...
>>
>> Any easier approaches?
>>
>> "persp" does not allow me to use mouse to rotate....
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide!
>> http://www.R-project.org/posting-guide.html
>>
>
>
> Have you seen the example in 'rgl' man page?
> It seems sufficient something like:
> rgl.surface(x,y,z)
>
> In that example, is also showed how to colorize the surface.

And an in-development update to rgl adds a number of new routines with
interfaces similar to ones from the graphics package.  For example,
persp3d is probably what Michael wants.

If you like playing with experimental versions and don't mind having
defaults changing with new releases, etc., you can download a recent
build from

http://www.stats.uwo.ca/faculty/murdoch/software

Bug reports and suggestions about the new stuff would be welcome.

Duncan

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there a way to draw 3d plot?

Gregory Snow
In reply to this post by LosemindL
There is also the rotate.persp function in the TeachingDemos package.
It creates a set of slider bars that you can move with the mouse to
change the different options to persp including the angles.  It is not
quite as convenient as clicking in the plot and dragging like rgl
allows, but it does have the advantage that when you have the plot you
like, you can see what the current settings are and recreate the same
plot using persp and those settings rather than having to remember how
you rotated the graph interactively (you can query the current rotation
in rgl as well and set it by command in future plots).


--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[hidden email]
(801) 408-8111
 

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Michael
Sent: Friday, May 26, 2006 1:25 AM
To: Uwe Ligges
Cc: [hidden email]
Subject: Re: [R] Is there a way to draw 3d plot?

On 5/26/06, Uwe Ligges <[hidden email]> wrote:

>
> Michael wrote:
>
> > Hi all,
> >
> > I have a 2D matrix, which has 100 rows, and 100 columns,
> >
> > I have a 2D matrix, with 100 rows and 100 columns,
> >
> > I want to display it using 3D plot, much like plot3d and mesh/surf
> functions
> > in matlab.
> >
> > Specifically, in matlab, I just need to do the following:
> >
> > --------
> > [X, Y]=meshgrid([0:0.01:0.99, 0:0.01:0.99]); % Z is my 2D matrix,
> > surf(X, Y, Z);
> > --------
> >
> > Note that X and Y are created so that I can associate physical
> > meaning
> onto
> > the x and y axis of the 3D plot.
> >
> > For example, my 100 rows represent 0, 0.01, 0.02, ... 0.99 here.
> >
> > In Matlab I can also drag in the graphic window and see from
> > different visual angle and perspective of the 3D plot...
> >
> > Are there similar functions in R that (1) show 3D plot; (2) let me
> > manipulate view angles easily?
>
> (1) See ?persp
>
> (1) *and* (2): See package "rgl".
>
> Uwe Ligges
>
>
>
> Thanks a lot,

But a glance at "rgl" seems requireing "shape", etc... and very
complicated...

Any easier approaches?

"persp" does not allow me to use mouse to rotate....

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there a way to draw 3d plot?

Ritwik Sinha
Hi,

I am not aware what this function does in matlab, but I was wondering why
"cloud" or "wireframe" in the lattice package has not entered the
discussion. Sorry if I am being naive.

Ritwik.

http://darwin.cwru.edu/~rsinha

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there a way to draw 3d plot?

Gregory Snow

It may be that since the original poster is coming from matlab others considered it best to start with the persp function that does not require additional packages or the other complications that come with lattice/trellis graphics.

Actually my response indirectly brings cloud and wireframe into the discussion, if you look at the help page for rotate.persp in the TeachingDemos package you will also see help for rotate.cloud and rotate.wireframe functions.

-----Original Message-----
From: Ritwik Sinha [mailto:[hidden email]]
Sent: Mon 5/29/2006 9:19 AM
To: Greg Snow
Cc: [hidden email]
Subject: Re: [R] Is there a way to draw 3d plot?
 
Hi,

I am not aware what this function does in matlab, but I was wondering why
"cloud" or "wireframe" in the lattice package has not entered the
discussion. Sorry if I am being naive.

Ritwik.

http://darwin.cwru.edu/~rsinha


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Loading...