Hi to the list,
I'm searching to display in realtime some data read serial port. The
data is a 2D matrix and is read element wise from the serial, one
pixel each one (or more) seconds.
I'm running the script from "ipython -pylab" using the command "run
scriptname". After "loading" the script I interactively launch the
function that start the data acquisition and I would like to see the
acquired data so far. In the loop that perform the data acquisition
I'm currently calling this function to plot data:
def plot_data_in_itinere(data, **kwargs):
d = data.ravel()[find(data.ravel() > 0)]
m = d.mean()
vr = round(5*d.std() / m, 3)
xlabel('Mean Value: '+str(int(round(m)))+' -- Relative Variation: '+str(vr))
b,t = ylim()
first_plot = False
However the call to the function is "blocking". So the acquisition
time is longer (not only I have to wait the data but I have to wait
the plot too). Furthermore, this function plot the new data above the
old one, so the plot becomes slower and slower while the acquisition
goes on. If I uncommented the cla() line, I get a plot that is blank
most of the time and that shows the data only for a fraction of second
while the new plot is performed.
Is there a way to update (or substitute) the current showed matrix
data, deleting the old plots (in the axis). I have to confess that
I've have not understand well how the pylab interactive mode works.
Ideally the plot should be performed in background, while the script
goes on and wait the next data arrival. I've tried to do this with a
simple gtk app that embeds a matplotlib plot. Hoever, I don't know how
to send the application in background. I've tried to do something like
if __name__ == '__main__':
stdout = sys.stdout
a = array(randn(100)).reshape(10,10)
p = PlotScanApp(a)
print 'Start image update:'
for i in range(10):
the PlotScanApp implement the gui (full files attached). Running the
script the image should be updated with random data each 1 sec. but
only the first image is showed. I suppose this is not the way to put a
gui drawing app in background...
Any hints in how to do in the right way this gtk app that when
required update the plot?
Thank a lot.
microplotlib.py (3.19 KB)
microlib.gladep (277 Bytes)