Quantcast

3D plot experiments

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

3D plot experiments

John Porter-5
Hi,
I have written some code which generates 3D plots, this was inspired by
the 3D axes code posted recently.  The basic idea is that 2D Artist
elements have their 'draw' method subverted to generate the projected 3D
coordinates. The plot is interactive and allows panning and tilting of
the graph by pressing and holding mouse-2.

I am new to this list, and was wondering where I should post the code
(it consists of two modules).

This example code here generates the attached png:

def run1():
     delta = 0.025
     x = y = p.arange(-3.0, 3.0, delta)
     X, Y = p.meshgrid(x,y)

     Z1 = p.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
     Z2 = p.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
     Z = Z2-Z1

     X = X * 10
     Y = Y * 10
     Z = Z * 500

     fig = p.figure()
     ax = mplot3d.Axes3D(fig)
     ax.plot_surface(X,Y,Z, div=10)

     ax.set_xlabel('X')
     ax.set_ylabel('Y')
     ax.set_zlabel('Z')

     fig.add_axes(ax)
     p.savefig("surface.png", dpi=40)
     p.show()



surface.png (60K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 3D plot experiments

John Hunter-8
>>>>> "John" == John Porter <[hidden email]> writes:

    John>      fig = p.figure() ax = mplot3d.Axes3D(fig)

Very nice screenshot!! -- did you intend to the mplot3d module so we
could test ourselves?

JDH




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 3D plot experiments

John Porter-5
John Hunter wrote:

>>>>>>"John" == John Porter <[hidden email]> writes:
>>>>>>            
>>>>>>
>
>    John>      fig = p.figure() ax = mplot3d.Axes3D(fig)
>
>Very nice screenshot!! -- did you intend to the mplot3d module so we
>could test ourselves?
>
>JDH
>
>
>  
>
I will, but it's very much work in progress....
There are hardly any comments, but there are a few tests at the bottom
of mplot3d.

John


mplot3d.py (54K) Download Attachment
proj3d.py (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 3D plot experiments

Fernando Perez-2
In reply to this post by John Porter-5
John Porter wrote:
> Hi,
> I have written some code which generates 3D plots, this was inspired by
> the 3D axes code posted recently.  The basic idea is that 2D Artist
> elements have their 'draw' method subverted to generate the projected 3D
> coordinates. The plot is interactive and allows panning and tilting of
> the graph by pressing and holding mouse-2.
>
> I am new to this list, and was wondering where I should post the code
> (it consists of two modules).

Very cool!  I can report that it works under ipython -pylab with the TkAgg
backend as well, using stock mpl 0.83.2.

Excellent work!

Cheers,

f


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Loading...