SourceForge logo
SourceForge logo
Menu

matplotlib-devel

Hello Everyone
 This is my first post, I really enjoy using python/numpy/scipy/matplotlib
- great replacement for matlab. I am having a problem, with plot 1 point at
a time. i am attempt to emulate an issue in the lab, where we get samples
every second and plot them. The figure becomes non-responsive and eventually
stops plotting, does anyone have an idea.
Cheers
Ray
*Code*
*------------------*
from numpy import *
from scipy import *
from pylab import *
import time;
ion()
figure(1)
subplot(412);plot([925],[0.296000],'o')
subplot(413);plot([925],[0.247000],'o')
subplot(414);plot([925],[0.145000],'o')
subplot(411);plot([926],[0.516000],'o')
time.sleep(1)
subplot(412);plot([926],[0.770000],'o')
subplot(413);plot([926],[0.820000],'o')
subplot(414);plot([926],[0.405000],'o')
subplot(411);plot([927],[0.704000],'o')
time.sleep(1)
subplot(412);plot([927],[0.721000],'o')
subplot(413);plot([927],[0.996000],'o')
subplot(414);plot([927],[0.219000],'o')
subplot(411);plot([928],[0.414000],'o')
time.sleep(1)
subplot(412);plot([928],[0.281000],'o')
subplot(413);plot([928],[0.066000],'o')
subplot(414);plot([928],[0.398000],'o')
subplot(411);plot([929],[0.718000],'o')
subplot(412);plot([929],[0.247000],'o')
subplot(413);plot([929],[0.887000],'o')
subplot(414);plot([929],[0.562000],'o')
subplot(411);plot([930],[0.386000],'o')
time.sleep(1)
subplot(412);plot([930],[0.173000],'o')
subplot(413);plot([930],[0.678000],'o')
subplot(414);plot([930],[0.635000],'o')
subplot(411);plot([931],[0.746000],'o')
time.sleep(1)
subplot(412);plot([931],[0.332000],'o')
subplot(413);plot([931],[0.468000],'o')
subplot(414);plot([931],[0.373000],'o')
subplot(411);plot([932],[0.568000],'o')
time.sleep(1)
subplot(412);plot([932],[0.929000],'o')
subplot(413);plot([932],[0.096000],'o')
subplot(414);plot([932],[0.132000],'o')
subplot(411);plot([933],[0.840000],'o')
time.sleep(1)
subplot(412);plot([933],[0.946000],'o')
subplot(413);plot([933],[0.607000],'o')
subplot(414);plot([933],[0.094000],'o')
subplot(411);plot([934],[0.690000],'o')
time.sleep(1)
subplot(412);plot([934],[0.330000],'o')
subplot(413);plot([934],[0.955000],'o')
subplot(414);plot([934],[0.101000],'o')
subplot(411);plot([935],[0.931000],'o')
time.sleep(1)
subplot(412);plot([935],[0.515000],'o')
subplot(413);plot([935],[0.444000],'o')
subplot(414);plot([935],[0.425000],'o')
subplot(411);plot([936],[0.960000],'o')
time.sleep(1)
subplot(412);plot([936],[0.676000],'o')
subplot(413);plot([936],[0.295000],'o')
subplot(414);plot([936],[0.861000],'o')
subplot(411);plot([937],[0.564000],'o')
time.sleep(1)
subplot(412);plot([937],[0.948000],'o')
subplot(413);plot([937],[0.159000],'o')
subplot(414);plot([937],[0.512000],'o')
subplot(411);plot([938],[0.884000],'o')
time.sleep(1)
subplot(412);plot([938],[0.542000],'o')
subplot(413);plot([938],[0.409000],'o')
subplot(414);plot([938],[0.079000],'o')
subplot(411);plot([939],[0.194000],'o')
time.sleep(1)
subplot(412);plot([939],[0.910000],'o')
subplot(413);plot([939],[0.901000],'o')
subplot(414);plot([939],[0.153000],'o')
subplot(411);plot([940],[0.183000],'o')
time.sleep(1)
subplot(412);plot([940],[0.578000],'o')
subplot(413);plot([940],[0.241000],'o')
subplot(414);plot([940],[0.484000],'o')
subplot(411);plot([941],[0.261000],'o')
time.sleep(1)
subplot(412);plot([941],[0.436000],'o')
subplot(413);plot([941],[0.120000],'o')
subplot(414);plot([941],[0.798000],'o')
subplot(411);plot([942],[0.339000],'o')
time.sleep(1)
subplot(412);plot([942],[0.927000],'o')
subplot(413);plot([942],[0.964000],'o')
subplot(414);plot([942],[0.526000],'o')
subplot(411);plot([943],[0.289000],'o')
time.sleep(1)
subplot(412);plot([943],[0.167000],'o')
subplot(413);plot([943],[0.695000],'o')
subplot(414);plot([943],[0.788000],'o')
subplot(411);plot([944],[0.863000],'o')
time.sleep(1)
subplot(412);plot([944],[0.054000],'o')
subplot(413);plot([944],[0.568000],'o')
subplot(414);plot([944],[0.054000],'o')
subplot(411);plot([945],[0.858000],'o')
time.sleep(1)
subplot(412);plot([945],[0.461000],'o')
subplot(413);plot([945],[0.916000],'o')
subplot(414);plot([945],[0.549000],'o')
subplot(411);plot([946],[0.575000],'o')
time.sleep(1)
subplot(412);plot([946],[0.056000],'o')
subplot(413);plot([946],[0.331000],'o')
subplot(414);plot([946],[0.864000],'o')
subplot(411);plot([947],[0.650000],'o')
time.sleep(1)
subplot(412);plot([947],[0.205000],'o')
subplot(413);plot([947],[0.036000],'o')
subplot(414);plot([947],[0.951000],'o')
subplot(411);plot([948],[0.289000],'o')
time.sleep(1)
subplot(412);plot([948],[0.446000],'o')
subplot(413);plot([948],[0.132000],'o')
subplot(414);plot([948],[0.562000],'o')
subplot(411);plot([949],[0.084000],'o')
time.sleep(1)
subplot(412);plot([949],[0.429000],'o')
subplot(413);plot([949],[0.451000],'o')
subplot(414);plot([949],[0.994000],'o')
subplot(411);plot([950],[0.520000],'o')
time.sleep(1)
subplot(412);plot([950],[0.280000],'o')
subplot(413);plot([950],[0.575000],'o')
subplot(414);plot([950],[0.152000],'o')
subplot(411);plot([951],[0.253000],'o')
time.sleep(1)
subplot(412);plot([951],[0.845000],'o')
subplot(413);plot([951],[0.973000],'o')
subplot(414);plot([951],[0.062000],'o')
subplot(411);plot([952],[0.669000],'o')
time.sleep(1)
subplot(412);plot([952],[0.583000],'o')
subplot(413);plot([952],[0.037000],'o')
subplot(414);plot([952],[0.179000],'o')
subplot(411);plot([953],[0.886000],'o')
time.sleep(1)
subplot(412);plot([953],[0.577000],'o')
subplot(413);plot([953],[0.670000],'o')
subplot(414);plot([953],[0.635000],'o')
subplot(411);plot([954],[0.609000],'o')
time.sleep(1)
subplot(412);plot([954],[0.058000],'o')
subplot(413);plot([954],[0.978000],'o')
subplot(414);plot([954],[0.341000],'o')
subplot(411);plot([955],[0.643000],'o')
time.sleep(1)
subplot(412);plot([955],[0.130000],'o')
subplot(413);plot([955],[0.563000],'o')
subplot(414);plot([955],[0.127000],'o')
subplot(411);plot([956],[0.068000],'o')
time.sleep(1)
subplot(412);plot([956],[0.405000],'o')
subplot(413);plot([956],[0.574000],'o')
subplot(414);plot([956],[0.135000],'o')
subplot(411);plot([957],[0.967000],'o')
time.sleep(1)
subplot(412);plot([957],[0.382000],'o')
subplot(413);plot([957],[0.191000],'o')
subplot(414);plot([957],[0.331000],'o')
subplot(411);plot([958],[0.409000],'o')
time.sleep(1)
subplot(412);plot([958],[0.053000],'o')
subplot(413);plot([958],[0.597000],'o')
subplot(414);plot([958],[0.516000],'o')
subplot(411);plot([959],[0.102000],'o')
time.sleep(1)
subplot(412);plot([959],[0.972000],'o')
subplot(413);plot([959],[0.199000],'o')
subplot(414);plot([959],[0.678000],'o')
subplot(411);plot([960],[0.200000],'o')
time.sleep(1)
subplot(412);plot([960],[0.070000],'o')
subplot(413);plot([960],[0.935000],'o')
subplot(414);plot([960],[0.803000],'o')
subplot(411);plot([961],[0.441000],'o')
time.sleep(1)
subplot(412);plot([961],[0.881000],'o')
subplot(413);plot([961],[0.094000],'o')
subplot(414);plot([961],[0.640000],'o')
subplot(411);plot([962],[0.955000],'o')
time.sleep(1)
subplot(412);plot([962],[0.997000],'o')
subplot(413);plot([962],[0.664000],'o')
subplot(414);plot([962],[0.536000],'o')
subplot(411);plot([963],[0.669000],'o')
time.sleep(1)
subplot(412);plot([963],[0.389000],'o')
subplot(413);plot([963],[0.633000],'o')
subplot(414);plot([963],[0.488000],'o')
subplot(411);plot([964],[0.825000],'o')
time.sleep(1)
subplot(412);plot([964],[0.502000],'o')
subplot(413);plot([964],[0.689000],'o')
subplot(414);plot([964],[0.804000],'o')
subplot(411);plot([965],[0.068000],'o')
time.sleep(1)
subplot(412);plot([965],[0.542000],'o')
subplot(413);plot([965],[0.860000],'o')
subplot(414);plot([965],[0.672000],'o')
subplot(411);plot([966],[0.070000],'o')
time.sleep(1)
subplot(412);plot([966],[0.247000],'o')
subplot(413);plot([966],[0.613000],'o')
subplot(414);plot([966],[0.288000],'o')
subplot(411);plot([967],[0.315000],'o')
time.sleep(1)
subplot(412);plot([967],[0.228000],'o')
subplot(413);plot([967],[0.452000],'o')
subplot(414);plot([967],[0.283000],'o')
subplot(411);plot([968],[0.241000],'o')
time.sleep(1)
subplot(412);plot([968],[0.267000],'o')
subplot(413);plot([968],[0.269000],'o')
subplot(414);plot([968],[0.558000],'o')
subplot(411);plot([969],[0.282000],'o')
time.sleep(1)
subplot(412);plot([969],[0.748000],'o')
subplot(413);plot([969],[0.323000],'o')
subplot(414);plot([969],[0.190000],'o')
subplot(411);plot([970],[0.236000],'o')
time.sleep(1)
subplot(412);plot([970],[0.193000],'o')
subplot(413);plot([970],[0.244000],'o')
subplot(414);plot([970],[0.464000],'o')
subplot(411);plot([971],[0.728000],'o')
time.sleep(1)
subplot(412);plot([971],[0.174000],'o')
subplot(413);plot([971],[0.791000],'o')
subplot(414);plot([971],[0.988000],'o')
subplot(411);plot([972],[0.984000],'o')
time.sleep(1)
subplot(412);plot([972],[0.890000],'o')
subplot(413);plot([972],[0.140000],'o')
subplot(414);plot([972],[0.463000],'o')
subplot(411);plot([973],[0.284000],'o')
time.sleep(1)
subplot(412);plot([973],[0.110000],'o')
subplot(413);plot([973],[0.139000],'o')
subplot(414);plot([973],[0.400000],'o')
subplot(411);plot([974],[0.919000],'o')
time.sleep(1)
subplot(412);plot([974],[0.038000],'o')
subplot(413);plot([974],[0.519000],'o')
subplot(414);plot([974],[0.206000],'o')
subplot(411);plot([975],[0.645000],'o')
time.sleep(1)
subplot(412);plot([975],[0.854000],'o')
subplot(413);plot([975],[0.276000],'o')
subplot(414);plot([975],[0.975000],'o')
subplot(411);plot([976],[0.624000],'o')
time.sleep(1)
subplot(412);plot([976],[0.031000],'o')
subplot(413);plot([976],[0.359000],'o')
subplot(414);plot([976],[0.908000],'o')
subplot(411);plot([977],[0.675000],'o')
time.sleep(1)
subplot(412);plot([977],[0.810000],'o')
subplot(413);plot([977],[0.349000],'o')
subplot(414);plot([977],[0.355000],'o')
subplot(411);plot([978],[0.430000],'o')
time.sleep(1)
subplot(412);plot([978],[0.445000],'o')
subplot(413);plot([978],[0.423000],'o')
subplot(414);plot([978],[0.813000],'o')
subplot(411);plot([979],[0.787000],'o')
time.sleep(1)
subplot(412);plot([979],[0.467000],'o')
subplot(413);plot([979],[0.276000],'o')
subplot(414);plot([979],[0.402000],'o')
subplot(411);plot([980],[0.089000],'o')
time.sleep(1)
subplot(412);plot([980],[0.664000],'o')
subplot(413);plot([980],[0.671000],'o')
subplot(414);plot([980],[0.913000],'o')
subplot(411);plot([981],[0.247000],'o')
time.sleep(1)
subplot(412);plot([981],[0.382000],'o')
subplot(413);plot([981],[0.939000],'o')
subplot(414);plot([981],[0.277000],'o')
subplot(411);plot([982],[0.259000],'o')
time.sleep(1)
subplot(412);plot([982],[0.777000],'o')
subplot(413);plot([982],[0.524000],'o')
subplot(414);plot([982],[0.068000],'o')
subplot(411);plot([983],[0.580000],'o')
time.sleep(1)
subplot(412);plot([983],[0.346000],'o')
subplot(413);plot([983],[0.607000],'o')
subplot(414);plot([983],[0.833000],'o')
subplot(411);plot([984],[0.300000],'o')
time.sleep(1)
subplot(412);plot([984],[0.626000],'o')
subplot(413);plot([984],[0.837000],'o')
subplot(414);plot([984],[0.685000],'o')
subplot(411);plot([985],[0.386000],'o')
time.sleep(1)
subplot(412);plot([985],[0.957000],'o')
subplot(413);plot([985],[0.701000],'o')
subplot(414);plot([985],[0.657000],'o')
subplot(411);plot([986],[0.631000],'o')
time.sleep(1)
subplot(412);plot([986],[0.121000],'o')
subplot(413);plot([986],[0.912000],'o')
subplot(414);plot([986],[0.567000],'o')
subplot(411);plot([987],[0.088000],'o')
time.sleep(1)
subplot(412);plot([987],[0.279000],'o')
subplot(413);plot([987],[0.024000],'o')
subplot(414);plot([987],[0.114000],'o')
subplot(411);plot([988],[0.035000],'o')
time.sleep(1)
subplot(412);plot([988],[0.025000],'o')
subplot(413);plot([988],[0.267000],'o')
subplot(414);plot([988],[0.251000],'o')
subplot(411);plot([989],[0.861000],'o')
time.sleep(1)
subplot(412);plot([989],[0.909000],'o')
subplot(413);plot([989],[0.564000],'o')
subplot(414);plot([989],[0.582000],'o')
subplot(411);plot([990],[0.211000],'o')
time.sleep(1)
subplot(412);plot([990],[0.921000],'o')
subplot(413);plot([990],[0.915000],'o')
subplot(414);plot([990],[0.044000],'o')
subplot(411);plot([991],[0.808000],'o')
time.sleep(1)
subplot(412);plot([991],[0.455000],'o')
subplot(413);plot([991],[0.846000],'o')
subplot(414);plot([991],[0.385000],'o')
subplot(411);plot([992],[0.647000],'o')
time.sleep(1)
subplot(412);plot([992],[0.723000],'o')
subplot(413);plot([992],[0.112000],'o')
subplot(414);plot([992],[0.017000],'o')
subplot(411);plot([993],[0.689000],'o')
time.sleep(1)
subplot(412);plot([993],[0.635000],'o')
subplot(413);plot([993],[0.225000],'o')
subplot(414);plot([993],[0.599000],'o')
subplot(411);plot([994],[0.056000],'o')
time.sleep(1)
subplot(412);plot([994],[0.534000],'o')
subplot(413);plot([994],[0.271000],'o')
subplot(414);plot([994],[0.774000],'o')
subplot(411);plot([995],[0.837000],'o')
time.sleep(1)
subplot(412);plot([995],[0.408000],'o')
subplot(413);plot([995],[0.363000],'o')
subplot(414);plot([995],[0.796000],'o')
subplot(411);plot([996],[0.839000],'o')
time.sleep(1)
subplot(412);plot([996],[0.581000],'o')
subplot(413);plot([996],[0.063000],'o')
subplot(414);plot([996],[0.404000],'o')
subplot(411);plot([997],[0.230000],'o')
time.sleep(1)
subplot(412);plot([997],[0.731000],'o')
subplot(413);plot([997],[0.478000],'o')
subplot(414);plot([997],[0.274000],'o')
subplot(411);plot([998],[0.319000],'o')
time.sleep(1)
subplot(412);plot([998],[0.870000],'o')
subplot(413);plot([998],[0.220000],'o')
subplot(414);plot([998],[0.364000],'o')
subplot(411);plot([999],[0.592000],'o')
time.sleep(1)
subplot(412);plot([999],[0.494000],'o')
subplot(413);plot([999],[0.320000],'o')
subplot(414);plot([999],[0.143000],'o')
On Fri, Aug 29, 2008 at 12:01 PM, Ray Salem <ray...@gm...> wrote:
> This is my first post, I really enjoy using python/numpy/scipy/matplotlib
> - great replacement for matlab. I am having a problem, with plot 1 point at
> a time. i am attempt to emulate an issue in the lab, where we get samples
> every second and plot them. The figure becomes non-responsive and eventually
> stops plotting, does anyone have an idea.
Yep, this is a bad idea. The line object in matplotlib is a fairly
heavy object which has a lot of stuff under the hood. Each plot
command creates a new line object. What you want to do is create just
one (or a few) line objects, each of which handles many points. Below
is the first pass naive implementation to show you how to do this --
you will probably want to improve on this by using a better data
structure to store the growing points, eg a buffer that drops old
points off the end, or a dynamically resizing numpy array which grows
intelligently when it gets full. The main point is that we create a
single line object and add the new data to it....
import time
import matplotlib
matplotlib.use('TkAgg')
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.collections as collections
plt.ion() # interactive plotting
fig = plt.figure()
ax = fig.add_subplot(111, autoscale_on=False)
xdata, ydata = [0.], [0.]
line, = ax.plot(xdata, ydata, 'o')
dt = 0.1
for i in range(100):
 x = xdata[-1] + dt
 y = np.sin(2*np.pi*x)
 xdata.append(x)
 ydata.append(y)
 line.set_data(xdata, ydata)
 ax.set_xlim(x-1, x)
 ax.set_ylim(-1.1, 1.1)
 fig.canvas.draw()
 time.sleep(0.1)
plt.show()
On Sat, Aug 30, 2008 at 9:49 AM, Ray Salem <ray...@gm...> wrote:
> Hey John. Your suggestion has definitely made a large improvement, but while
> it is still running, if you select any of the windows, python or the figure,
> the figure will still enter a state of non-response. I have tried something
> very similar in matlab and have observed no problems. Do you have any other
> advice or suggestions
Please respond on list so others can benefit and contribute to the
conversation. You need to "reply to all" to reply to the list.
In order to do this well, you need to use your user interface idle
handler. The example I used was just to illustrate the line handling,
but for real work you should set you update function in either an idle
handler or a timeout handler. Look in the examples/animation
directory http://matplotlib.sourceforge.net/examples/animation for
different examples for each user interface (see also the animations
cookbook tutorial at
http://www.scipy.org/Cookbook/Matplotlib/Animations).
The way to do this differs for each toolkit, and we have examples for
many in the examples directory I pointed you to above. Does anyone
have an example of how to do proper idle handling with tk?
JDH
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /