Hi,

While upgrading from matplotlib 0.91.2 to 0.98.2 my software stop working properly. I had to adapt one of my function to autoscale visible lines. Basically, the modified function seems to work but when I use it on a shared axes context I run into problem.

A small script in attachment illustrate the problem.
Actually, the second axes which sharex with first one, prevent the first one to be scaled properly. The script works properly with matplotlib 0.91.2 but fail (autoscaling not working) using 0.98.2 Am I doing something wrong in my autoscale function while updating the axs.dataLim ? Or is it something more tricky?

Thanks in advance for your help.

David
import matplotlib

def autoscale_visible_lines(axs):
    """
    Function to autoscale only on visible lines.
    """
    ignore = True
    for line in (axs.lines):
        if not line.get_visible():
            continue #jump to next line if this one is not visible
        if matplotlib.__version__ == '0.98.2':
            axs.dataLim.update_from_data_xy(line.get_xydata(),
                                            ignore)
        else:
            axs.dataLim.update_numerix(line.get_xdata(),
                                       line.get_ydata(),
                                       ignore)
        ignore = False
    axs.autoscale_view()
    return None


import pylab as pl

if __name__ == "__main__":

    axs1 = pl.subplot(111)
    t = pl.arange(0.01, 190.0, 0.01)
    s1 = pl.log(t)
    l11, = pl.plot(t, s1, 'b-')
    l12, = pl.plot(t-50, s1+10)

    l11.set_visible(False)
    l12.set_visible(True)

    twinx = True
    if twinx:
        axs2 = pl.gcf().add_axes(axs1.get_position(),
                                 sharex=axs1, frameon=False)
        l21, = pl.plot([1], [1], 'r.')

    autoscale_visible_lines(axs1)

    pl.show()
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to