[Matplotlib-users] detect axes belonging to a colorbar
jfoxrabinovitz at gmail.com
Fri Aug 19 12:58:14 EDT 2016
On a related note, I was thinking that doing something like
`fig.findobj(mpl.colorbar.ColorbarBase)` would help you, but it raises an
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
line 975, in findobj
line 307, in __init__
line 459, in set_label
line 448, in _set_label
AttributeError: 'Rectangle' object has no attribute 'set_ylabel'
What is wrong about the way I am trying to use `findobj`?
Here is the code I was testing with, for reference:
import numpy as np
import matplotlib as mpl
from matplotlib import pyplot as plt
x = np.arange(10)
y = np.arange(10)
X, Y = np.meshgrid(x, y)
z = X * Y
ax = plt.pcolor(X, Y, z)
fig = ax.figure
On Fri, Aug 19, 2016 at 10:26 AM, Benjamin Root <ben.v.root at gmail.com>
> 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,
> Ben Root
> On Wed, Aug 17, 2016 at 5:01 AM, <aeuii at posteo.de> wrote:
>> I would like to iterate over fig.axes and apply some changes to regular
>> axes and skip those belonging to colorbars.
>> What's the best way (having only fig object) to detect if an axis
>> belongs to a colorbar or not?
>> Thanks for an advice.
>> Best regards,
>> Matplotlib-users mailing list
>> Matplotlib-users at python.org
> Matplotlib-users mailing list
> Matplotlib-users at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Matplotlib-users