Ryan May wrote:
Hi list,
I'm trying to get a dynamic plot running.
I'm stuck at feeding the data to the lines.
basically I've a callback that receives a (y,x1,x2) tuple and I would
like to add the 2 points to the two matplotlib.lines of the figure.
should I handle a copy of xdata/ydata and gives the updated set to
set_x/ydata() for one point?
I tried to get_data() and append to it, but It's a MaskedArray and I
guess it means its a really bad idea to try this way.
probably a new class inheriting figure and overriding
get_data()//set_data() could do the trick?
any advice on a _clean_ design I could use?
You can add a value to an array using np.concatenate:
x,y = line.get_data()
x = np.concatenate((x, [x0]))
y = np.concatenate((y, [y0]))
line.set_data([x,y])
This is rather inefficient however if you're adding lots of points or if
there are just a lot of point in x any in general. If you know how many
points you're going to end up with, you could create mostly empty
MaskedArrays and keep the extra points masked until you get the data.
Ryan
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
thanks Ryan,
It does work and I'll use that for now.
the idea is to have a gkrellm-like UI in which you can monitor system
usage 'live'
I guess I could have a 'window of event', just keeping the last 1000
points and move the xlim as a window:
ax.set_xlim(xmin=currentmin+time,xmax=currentmax+time)
but something sounds plain wrong, It sounds like there's too much
useless calculations and data copied.
would it be a good idea to have an array of 1000 points and shift it
left every round to add the new point at the end?
···
On Fri, Jul 3, 2009 at 8:32 AM, guillaume ranquet <granquet@...2572... > <mailto:granquet@…2572…>> wrote:
----
This message contains confidential information and may contain information that is legally privileged. If you have received this message by mistake, please immediately notify us and delete the original message. Thank you.
Ce message contient des informations confidentielles. S'il vous est parvenu par erreur, merci de bien vouloir nous en aviser par retour, de n'en faire aucun usage et de n'en garder aucune copie.
----