Skip to content

Commit 961742c

Browse files
committed
Make colorbars constructible with dataless ScalarMappables.
This allows creating "bare" colorbars with the one-liner fig.colorbar(cm.ScalarMappable(norm=norm, cmap=cmap))
1 parent 4dbbd22 commit 961742c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/matplotlib/colorbar.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,8 @@ class Colorbar(ColorbarBase):
10691069
def __init__(self, ax, mappable, **kw):
10701070
# Ensure the given mappable's norm has appropriate vmin and vmax set
10711071
# even if mappable.draw has not yet been called.
1072-
mappable.autoscale_None()
1072+
if mappable.get_array() is not None:
1073+
mappable.autoscale_None()
10731074

10741075
self.mappable = mappable
10751076
kw['cmap'] = cmap = mappable.cmap

0 commit comments

Comments
 (0)