Skip to content

Add a colorbar() method to ScalarMappable? #25880

Open
@greglucas

Description

@greglucas

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions