Replot ?

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

Thanks in advance
marco

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

···

On 4/16/07, marco cammarata <marco.cammarata@...291...> wrote: