<div dir="ltr">mpl.colorbar.ColorbarBase is not a subclass of Artist, so findobj() doesn't detect that you want to match against that object type.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 19, 2016 at 12:58 PM, Joseph Fox-Rabinovitz <span dir="ltr"><<a href="mailto:jfoxrabinovitz@gmail.com" target="_blank">jfoxrabinovitz@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>On a related note, I was thinking that doing something like <span style="font-family:monospace,monospace">`fig.findobj(mpl.colorbar.<wbr>ColorbarBase)`</span> would help you, but it raises an error instead:<br><br><div style="margin-left:40px"><span style="font-family:monospace,monospace">Traceback (most recent call last):</span><br><span style="font-family:monospace,monospace">  File "<stdin>", line 1, in <module></span><br><span style="font-family:monospace,monospace">  File "/home/jfoxrabi/miniconda3/<wbr>lib/python3.5/site-packages/<wbr>matplotlib/artist.py", line 975, in findobj</span><br><span style="font-family:monospace,monospace">    if matchfunc(c):</span><br><span style="font-family:monospace,monospace">  File "/home/jfoxrabi/miniconda3/<wbr>lib/python3.5/site-packages/<wbr>matplotlib/colorbar.py", line 307, in __init__</span><br><span style="font-family:monospace,monospace">    self.set_label(label)</span><br><span style="font-family:monospace,monospace">  File "/home/jfoxrabi/miniconda3/<wbr>lib/python3.5/site-packages/<wbr>matplotlib/colorbar.py", line 459, in set_label</span><br><span style="font-family:monospace,monospace">    self._set_label()</span><br><span style="font-family:monospace,monospace">  File "/home/jfoxrabi/miniconda3/<wbr>lib/python3.5/site-packages/<wbr>matplotlib/colorbar.py", line 448, in _set_label</span><br><span style="font-family:monospace,monospace">    self.ax.set_ylabel(self._<wbr>label, **self._labelkw)</span><br><span style="font-family:monospace,monospace">AttributeError: 'Rectangle' object has no attribute 'set_ylabel'</span><br></div><div style="margin-left:40px"><span style="font-family:monospace,monospace"></span></div><br></div><div>What is wrong about the way I am trying to use `<span style="font-family:monospace,monospace">findobj</span>`?<br></div><div><br></div>Here is the code I was testing with, for reference:<br></div><span style="font-family:monospace,monospace"><br></span><div><div style="margin-left:40px"><span style="font-family:monospace,monospace">import numpy as np</span><br><span style="font-family:monospace,monospace">import matplotlib as mpl</span><br><span style="font-family:monospace,monospace">from matplotlib import pyplot as plt</span><br><span style="font-family:monospace,monospace">x = np.arange(10)</span><br><span style="font-family:monospace,monospace">y = np.arange(10)</span><br><span style="font-family:monospace,monospace">X, Y = np.meshgrid(x, y)</span><br><span style="font-family:monospace,monospace">z = X * Y</span><br><span style="font-family:monospace,monospace">ax = plt.pcolor(X, Y, z)</span><br><span style="font-family:monospace,monospace">plt.colorbar()</span><br><span style="font-family:monospace,monospace">fig = ax.figure</span><br><span style="font-family:monospace,monospace">fig.findobj(mpl.colorbar.<wbr>ColorbarBase)</span></div><span style="font-family:monospace,monospace"><br></span><br><br>    -Joe<br><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 19, 2016 at 10:26 AM, Benjamin Root <span dir="ltr"><<a href="mailto:ben.v.root@gmail.com" target="_blank">ben.v.root@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>No, I don't think there is a way, really. From the perspective of the figure object, the colorbar looks just like another axes object. There might be a trick that might work in some cases, but they would be highly fragile. It would be better to just capture the colorbar object directly, somehow.<br><br></div>Ben Root<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 17, 2016 at 5:01 AM,  <span dir="ltr"><<a href="mailto:aeuii@posteo.de" target="_blank">aeuii@posteo.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I would like to iterate over fig.axes and apply some changes to regular<br>
axes and skip those belonging to colorbars.<br>
<br>
What's the best way (having only fig object) to detect if an axis<br>
belongs to a colorbar or not?<br>
<br>
Thanks for an advice.<br>
<br>
Best regards,<br>
Stefan<br>
<br>
______________________________<wbr>_________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/matplotlib-users</a><br>
</blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/matplotlib-users</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>