On Thu, Jul 3, 2008 at 8:42 AM, John Kitchin <[EMAIL PROTECTED]> wrote: > Thanks Matthias. That is a helpful example. > > I have been trying to figure out how to recursively examine all the objects > in fig to see if there is a particular settable property. It seems like the > algorithm has to be recursive so that it goes deep into all the lists, etc. > I have not figured out how to know when you have reached the bottom/end of a > trail. > > Such a function would let me set any text property in the whole figure > without needing to know if it was a text object, label, legend, etc... maybe > that is not as valuable as I think it would be though.
This is a good idea, and I just added an artist method "findobj" in svn that recursively calls get_children and implements a match criteria (class instance or callable filter). There is also a pyplot/pylab wrapper that operates on current figure by default. Here is an example: import numpy as np import matplotlib.pyplot as plt import matplotlib.text as text a = np.arange(0,3,.02) b = np.arange(0,3,.02) c = np.exp(a) d = c[::-1] fig = plt.figure() ax = fig.add_subplot(111) plt.plot(a,c,'k--',a,d,'k:',a,c+d,'k') plt.legend(('Model length', 'Data length', 'Total message length'), 'upper center', shadow=True) plt.ylim([-1,20]) plt.grid(False) plt.xlabel('Model complexity --->') plt.ylabel('Message length --->') plt.title('Minimum Message Length') # match on arbitrary function def myfunc(x): return hasattr(x, 'set_color') for o in fig.findobj(myfunc): o.set_color('blue') # match on class instances for o in fig.findobj(text.Text): o.set_fontstyle('italic') plt.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