Matthias Michler wrote: > On Thursday 26 February 2009 20:52:17 Christopher Brown wrote: >> Hi, >> >> If I have a figure: >> >> h = pp.figure(num=14) >> >> What is the best way to check to see if Figure 14 exists? I'm writing a >> function that adds plots to a figure window. I want the function to >> check if the figure exists, and if so, turn off autoscaling (using >> Eric's suggested axes.set_autoscale_on(False)) in case the user has zoomed. > > Hi Christopher, > > I don't know if my suggestion is the best way, but at least it may be > useful ...
I think your suggestion is the only way at present, but it suggests that we should provide this capability as part of the API; we don't want to force people to access the private _pylab_helpers module directly. Eric > > regards Matthias > > example code: > > import matplotlib > import matplotlib.pyplot as plt > > > for i in range(5)+[14]: > plt.figure(i) # generating some figures > > # get the figure numbers of all existing figures > fig_numbers = [x.num > for x in matplotlib._pylab_helpers.Gcf.get_all_fig_managers()] > > if 14 in fig_numbers: > print "figure 14 exists" > > if plt.figure(14).number in fig_numbers: > print "figure 14 exists" > > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users