.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/misc/findobj_demo.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. meta:: :keywords: codex .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_misc_findobj_demo.py: ============ Findobj Demo ============ Recursively find all objects that match some criteria .. GENERATED FROM PYTHON SOURCE LINES 8-43 .. image-sg:: /gallery/misc/images/sphx_glr_findobj_demo_001.png :alt: Minimum Message Length :srcset: /gallery/misc/images/sphx_glr_findobj_demo_001.png, /gallery/misc/images/sphx_glr_findobj_demo_001_2_00x.png 2.00x :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np 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, ax = plt.subplots() plt.plot(a, c, 'k--', a, d, 'k:', a, c + d, 'k') plt.legend(('Model length', 'Data length', 'Total message length'), loc='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') and not hasattr(x, 'set_facecolor') 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() .. _sphx_glr_download_gallery_misc_findobj_demo.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: findobj_demo.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: findobj_demo.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_