You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: regression with ScalarMappable and .set_array and autoscale_None #20902
We are creating manual ScalarMappable instances in some cases where colorbar creation is detached from the plotting event. Changed in #20511 an element-wise comparison of the color array is made, however, with ScalarMappable.set_array there appears to be no assurances that the ._A attribute will support such comparison.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-1-adec5b1bbfd1> in <module>
6 pts = mpl.cm.ScalarMappable(norm=norm, cmap=cmap)
7 pts.set_array([0.1, 0.9])
----> 8 plt.colorbar(pts)
~/rms-python/envs/mpl34/lib/python3.7/site-packages/matplotlib/pyplot.py in colorbar(mappable, cax, ax, **kw)
2354 'an image (with imshow) or a contour set ('
2355 'with contourf).')
-> 2356 ret = gcf().colorbar(mappable, cax=cax, ax=ax, **kw)
2357 return ret
2358
~/rms-python/envs/mpl34/lib/python3.7/site-packages/matplotlib/figure.py in colorbar(self, mappable, cax, ax, use_gridspec, **kw)
1174 'panchor']
1175 cb_kw = {k: v for k, v in kw.items() if k not in NON_COLORBAR_KEYS}
-> 1176 cb = cbar.Colorbar(cax, mappable, **cb_kw)
1177
1178 self.sca(current_ax)
~/rms-python/envs/mpl34/lib/python3.7/site-packages/matplotlib/colorbar.py in __init__(self, ax, mappable, **kwargs)
1170 # even if mappable.draw has not yet been called.
1171 if mappable.get_array() is not None:
-> 1172 mappable.autoscale_None()
1173
1174 self.mappable = mappable
~/rms-python/envs/mpl34/lib/python3.7/site-packages/matplotlib/cm.py in autoscale_None(self)
474 if self._A is None:
475 raise TypeError('You must first set_array for mappable')
--> 476 self.norm.autoscale_None(self._A)
477 self.changed()
478
~/rms-python/envs/mpl34/lib/python3.7/site-packages/matplotlib/colors.py in autoscale_None(self, A)
1541 def autoscale_None(self, A):
1542 # docstring inherited.
-> 1543 super().autoscale_None(np.ma.array(A, mask=(A <= 0)))
1544
1545
TypeError: '<=' not supported between instances of 'list' and 'int'
Activity
anntzer commentedon Aug 31, 2021
This should be fixed by #18870 in 3.5, I don't know if @QuLogic wants to backport that to 3.4.4?
QuLogic commentedon Sep 2, 2021
Yes, I'm aware of that, but it seems to be a new feature. Also, it doesn't actually fix the problem, only the most directly accessible trigger of it.
anntzer commentedon Sep 3, 2021
What would be the other repros?
QuLogic commentedon Nov 16, 2021
Calling it directly, really.
But we probably won't have a 3.4.4, so I'll close as fixed in 3.5.