Updating a plot

Hello everybody,

I would like to create a plot from which I set the x data later. The method set_xdata works but the corresponding plot displays the initial x limits. Is it possible to update the plot automatically in order that the displayed plot has x limits corresponding to the newly set x data ?

Here is the script that fails:

import pylab
fig = pylab.figure()
ax = fig.add_subplot(111, label = ‘plot1’)
p, = ax.plot([1,2,3,4,5])
p.set_xdata([10,20,30,40,50])

ax.set_xlim([10,50])

fig.show()

to update the xlim I have to add the commented line.

thank you very much

Eric Pellegrini

Pellegrini Eric wrote:

Hello everybody,

I would like to create a plot from which I set the x data later. The
method set_xdata works but the corresponding plot displays the initial
x limits. Is it possible to update the plot automatically in order
that the displayed plot has x limits corresponding to the newly set x
data ?

Here is the script that fails:

import pylab
fig = pylab.figure()
ax = fig.add_subplot(111, label = 'plot1')
p, = ax.plot([1,2,3,4,5])
p.set_xdata([10,20,30,40,50])
# ax.set_xlim([10,50])
fig.show()

to update the xlim I have to add the commented line.

thank you very much

Eric Pellegrini

I think this is more or less the same question asked by "C M" on April 8
on this list. Can you see if the response by Ryan May is sufficient for you?