continuous plotting..

Hello

I am trying to use this application to plot a diagram from a log file that is always active and storing data. I have written the following and I have issues once I touch the figure window it freezes…

from pylab import *
import time
val = 1

while True:
inData = load(‘c:\data.txt’)
x = inData[:,0]
y = inData[:,1]
plot(x,y,‘o’)
if val == 1:
show()
time.sleep(1)
if val == 0:
val = 0
time.sleep(1)
draw()

I am using the following program to create some dummy data:

import time
import math

def test():
for i in range(900):
for rad in
sineVal:
fileData = open(‘c:\data.txt’,‘a’)
time.sleep(1)
fileData.write(’%d’ % int(i))
fileData.write(’\t’)
fileData.write(’%f’ % math.sin(rad))
fileData.write(’\n’)
fileData.close()
print(’*’),

def makeArray():
tempArray = []
for i in range(0,360,180):
tempArray.append(i)
return
tempArray

sineVal = makeArray()

test()

You help and suggestion in the above matter will be most welcomed.

BR /ray

···

Never miss a thing. Make Yahoo your homepage.

Ray,

The first problem is that you are calling show() repeatedly, but show() should only be called once per script; it is used in non-interactive plotting. Now I see that you are trying to prevent that, but the code as it came out in your email does not do so--val never gets set to zero.

Note that by default, repeated calls to plot overlay more and more plot elements; I don't think this is what you want.

To get ideas, you might look at anim.py and strip_chart_demo.py in the examples directory.

Eric

ray sa wrote:

···

Hello

I am trying to use this application to plot a diagram from a log file that is always active and storing data. I have written the following and I have issues once I touch the figure window it freezes...

from pylab import *
import time
val = 1

while True:
    inData = load('c:\\data.txt')
    x = inData[:,0]
    y = inData[:,1]
    plot(x,y,'o')
    if val == 1:
        show()
    time.sleep(1)
    if val == 0:
        val = 0
    time.sleep(1)
    draw()

I am using the following program to create some dummy data:

import time
import math

def test():
    for i in range(900):
        for rad in sineVal:
            fileData = open('c:\\data.txt','a')
            time.sleep(1) fileData.write('%d' % int(i))
            fileData.write('\t')
            fileData.write('%f' % math.sin(rad))
            fileData.write('\n')
            fileData.close()
            print('*'),

def makeArray():
    tempArray =
    for i in range(0,360,180):
        tempArray.append(i)
    return tempArray

sineVal = makeArray()

test()

You help and suggestion in the above matter will be most welcomed.

Hello Ray,

There appears to be something wrong
with the way “val” is used in the first code section (if val==0:
val = 0 ?), unless it is modified externally somehow?

I would also suggest adding random values
or some such to make the test data non-periodic, so that it doesn’t always
look the same.

Best regards,

Brett McSweeney

ray sa <bizag007@…9…>

Sent by: matplotlib-users-bounces@lists.sourceforge.net
03/12/2007 09:50 AM

To

matplotlib-users@lists.sourceforge.net
cc

Subject

[Matplotlib-users] continuous plotting…

Hello

I am trying to use this application to plot a diagram from a log file that
is always active and storing data. I have written the following and I have
issues once I touch the figure window it freezes…

from pylab import *

import time

val = 1

while True:

inData = load('c:\\data.txt')

x = inData[:,0]

y = inData[:,1]

plot(x,y,'o')

if val == 1:

    show()

time.sleep(1)

if val == 0:

    val = 0

time.sleep(1)

draw()

I am using the following program to create some dummy data:

import time

import math

def test():

for i in range(900):

    for rad in sineVal:

        fileData = open('c:\\data.txt','a')

        time.sleep(1)  

        fileData.write('%d' % int(i))

        fileData.write('\t')

        fileData.write('%f' % math.sin(rad))

        fileData.write('\n')

        fileData.close()

        print('*'),

def makeArray():

tempArray = []

for i in range(0,360,180):

    tempArray.append(i)

return tempArray

sineVal = makeArray()

test()

You help and suggestion in the above matter will be most welcomed.

BR /ray

···

Never miss a thing. Make
Yahoo your homepage.


This email has been scanned by the MessageLabs Email Security System.

For more information please visit http://www.messagelabs.com/email

______________________________________________________________________`-------------------------------------------------------------------------

SF.Net email is sponsored by: The Future of Linux Business White Paper

from Novell. From the desktop to the data center, Linux is going

mainstream. Let it simplify your IT future.

http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4_______________________________________________

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

`

UNITED GROUP
This email message is the property of United Group. The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, you may not disclose, copy or distribute this email, nor take or omit to take any action in reliance on it. United Group accepts no liability for any damage caused by this email or any attachments due to viruses, interference, interception, corruption or unauthorised access.
If you have received this email in error, please notify United Group immediately by email to the sender’s email address and delete this document.