|
From: Amit F. <ami...@gm...> - 2008-03-23 08:56:03
|
Hi everyone,
I am using matplotlib to dynamically plot a graph with both my x and y
points taken from a measurement device. That is to say, in each
iteration of my while loop I'm reading two variables which I then want
to plot with matplotlib.
I wrote something which goes like this (disregard the Gnuplot - that's
what I'm trying to replace with matplotlib...)
import gpib, Numeric, time, Gnuplot, mymodule, threading
from pylab import *
def cooldown(filename, dmm_gpib, lake_gpib):
"""this program scans dummy and reads HP and Lakeshore"""
A = Numeric.arange(-1, 1, .1)
delay = 1
f = open(filename,'w')
X = []
Y = []
figure(2)
hold(False)
try:
while A[0]<10:
gpib.write(lake_fd, 'SDAT?')
gpib.write(hp_fd, 'read?')
time.sleep(delay)
val1 = float(gpib.read(lake_fd, 30))
val2 = float(gpib.read(hp_fd, 30))
X.append(val1)
Y.append(val2)
plot(X,Y,'.-')
f.write(str(val1) + '\t' + str(val2) + '\n')
f.flush()
I'm running this code in ipython with the -pylab option, so I don't need
to use show(). My question is, how do I maintain a *constant* xlabel and
ylabel without having to redraw them each time I append a point to the
graph? If I try xlabel('something') then obviously it's cleared each
time I use plot(X,Y).
Any ideas?
Thanks,
Amit.
|