On 4/16/07, marco cammarata <[EMAIL PROTECTED]> wrote: > Dear matplotlib users, > > I have the following problem, > > I need to plot an array of data as function of a parameter. > The example below will clarify what I mean. > The problem is that I don't know how to update the plot > > # (this x,y are to simulate my actual data) > x=arange(100) > y=x**2 > > xc=50 > xc_gt_0=where( (x>xc), x-xc, float('nan')) > pylab.plot(xc_gt_0,y) > pylab.show() > > Now I want to see the same plot after having changed the value of xc > from the shell. > > Any idea ? > I was thinking to something like this > > while (reply =! "exit"): > xc=raw_input("Inser the new value") > draw() > > but it doesn't work
Save the output of the plot command as a line instance >>> line, = pylab.plot(something) Then later update your xdata >>> xc = some_updated_data Then set the xdata (or ydata or both) of the line instance >>> line.set_xdata(xc) Then redraw your plot >>> pylab.draw() That's it! JDH ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users