[Tutor] hi

Vick vick1975 at orange.mu
Thu Aug 1 13:32:16 CEST 2013


Hi,

As per your request below, I have attached a stand-alone example (test3d.py)
of my problem. I am trying to plot in 3D using ion() from a loop.

The code should plot x,y,z coordinates from a loop in ion(). We should see
the plot line moving and the marker moving as well.

I have also attached a working 2d-plot (test2d.py) to show what it's
supposed to do. The 3d plot (test3d.py) should plot the same but with an
additional z coordinates and a z axis!

Thanks
Vick

-----Original Message-----
From: Oscar Benjamin [mailto:oscar.j.benjamin at gmail.com] 
Sent: Thursday, 01 August, 2013 01:42
To: Vick
Subject: Re: [Tutor] hi

On 31 July 2013 22:20, Vick <vick1975 at orange.mu> wrote:
> Hello,

Hi Vick,

I would prefer it if you would send questions like this to the tutor mailing
list rather than directly to me. This is because:
1) I'm often unable to respond and there are many other people there who
could help (I may be the only one there who understands ODEs but I'm
certainly not the only one who understands matplotlib).
2) It's helpful for others on the tutor mailing list to see the kind of
problems (and solutions) that people new to Python are working with.
3) Any problem/solution gets publicly archived for future reference.

> Can you help me please with plotting in 3D using ion()?
>
> My code is the following:
>
> from pylab import *
> #import pylab
> from mpl_toolkits.mplot3d.axes3d import Axes3D import 
> matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d
>
> plt.ion()
>
> fig = plt.figure(dpi=100)
> ax = axes3d.Axes3D(fig)#fig.add_subplot(111, projection = '3d')
>
>
> tn= mpf('300')#mpf('800')*dt
>
> for i in drange (t+dt, tn,dt):
>     mi = testran(i,mi,dt)
>     #print i+ dt,"       ", mi
>     a.append(mi[0])
>     b.append(mi[1])
>     z1.append(mi[2])
>     c.append(mi[6])
>     d.append(mi[7])
>     z2.append(mi[8])
>     #clf()
>     ax.plot(a,b,z1)#linestyle='None', marker='o', markersize = 5)
>     ax.plot(a,b,z1, marker='o', linestyle='None')
>     ax.plot(c,d,z2)
>     ax.plot(c,d,z2, marker='o', linestyle='None')
>     #draw()
>
> #grid()
> #show()
>
> I'm trying to plot in 3D, coordinates that are appended from a loop 
> using ion(), but it doesn't plot.

I get something different:

$ python plot3d.py
Traceback (most recent call last):
  File "plot3d.py", line 13, in <module>
    tn= mpf('300')#mpf('800')*dt
NameError: name 'mpf' is not defined

Where does the mpf function come from? There are many other symbols that are
not defined (t, dt, testran, ...) so presumably this code is incomplete
somehow.

Could you please make a complete example illustrating the problem you have
and then post it to the tutor list?


Oscar
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test2d.py
URL: <http://mail.python.org/pipermail/tutor/attachments/20130801/d9761732/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test3d.py
URL: <http://mail.python.org/pipermail/tutor/attachments/20130801/d9761732/attachment-0001.ksh>


More information about the Tutor mailing list