Description
Sorry to slightly hijack the thread here, but I think this may be a good opportunity to discuss whether
colorbar() could rather be a method on the ScalarMappable rather than on the Figure (we can always keep
figure.colorbar(...) available "forever", of course, for backcompat).
Indeed, in an call like fig.colorbar(mappable)
or fig.colorbar(mappable, ax=...)
or fig.colorbar(mappable, cax=...)
,
fig plays no role at all (*): the axes where the colorbar ends up is entirely determined by the mappable's axes (or by the ax
kwarg, or the cax kwarg.
(*) Actually I lied a bit: we currently check whether there's a layout engine on fig (but that actually seems more like a bug; we should really check that on mappable.axes.figure).
Originally posted by @anntzer in #25871 (comment)