autoscale using class library

Hi all, and thanks for amazing matplotlib. I devellop my

    > data processing / plotting software using glade, pygtk,
    > scipy and matplotlib 0.83.2.

    > I use the class library and I run into trouble with
    > autoscaling.

    > I expected that autoscale_view() function of axes class
    > would do autoscaling. But if I update the data using
    > set_data(), set_xdatat() or set_ydata() (of lines object)
    > and I call autoscale_view() of the corresponding axes and
    > then redraw the canvas, the scale is not changed and some
    > data points are thus out of the picture.

    > Do I miss or misunderstand something ?

The axes keeps a copy of the "dataLim" and won't automatically know if
you change the line's data. You need to call

  ax.update_datalim_numerix(x, y, ignore)

where x and y are the numerix arrays you pass to line.set_data.

If ignore is True, the previous data passed to the axes will be
ignored in computing the new datalim. If False, the datalim will
include the previous data and the current data you are passing it.

After this, a call to

ax.autoscale_view()

should work as you expect.

JDH

Hello,

No actually it doesn't work exactly as I expected.

I have different lines (at least two) that I would like to
update and also hide/show and I expected that autoscaling will take all
these aspects (updated data, hiden data) to scale the graph to all visible data.

The main problem is that old data limit is kept or totaly lost. The axes
scaling doesn't seem to work with the list of lines,
but is updated each time you add a line to the axes (as far as
I can undestand from the source code). So the scale can only be increased
but never decreased. Am I write or wrong ?

Furthermore I use the sharey stuff that complicated a bit the story.
So I don't think I can easelly do what I want using the axes class.
Maybe I should calculate the scaling in my software and set the min/max value.

If one of you have another idea please let me know.

Thanks for your help,

David

Selon John Hunter <jdhunter@...4...>:

···

    > I use the class library and I run into trouble with
    > autoscaling.

    > I expected that autoscale_view() function of axes class
    > would do autoscaling. But if I update the data using
    > set_data(), set_xdatat() or set_ydata() (of lines object)
    > and I call autoscale_view() of the corresponding axes and
    > then redraw the canvas, the scale is not changed and some
    > data points are thus out of the picture.

The axes keeps a copy of the "dataLim" and won't automatically know if
you change the line's data. You need to call

  ax.update_datalim_numerix(x, y, ignore)

where x and y are the numerix arrays you pass to line.set_data.

If ignore is True, the previous data passed to the axes will be
ignored in computing the new datalim. If False, the datalim will
include the previous data and the current data you are passing it.

After this, a call to

ax.autoscale_view()

should work as you expect.

JDH