FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[ENH]: Colorbar should support location kwarg that sets both orientation and ticklocation · Issue #22676 · matplotlib/matplotlib · GitHub

Repository navigation

[ENH]: Colorbar should support location kwarg that sets both orientation and ticklocation #22676

Closed

Description

Problem

When colorbar autocreates an Axes, one can pass location, which also sets the colorbar's orientation and the ticklocation (left for a left colorbar, right for a right colorbar, etc.). When one instead passes a manually created Axes (e.g. using inset_axes, as suggested by the colorbar_placement.py example), the location kwarg is not accepted (because things are directly passed to the Colorbar class); one needs to explicitly set orientation and ticklocation (the latter is not even documented by Figure.colorbar):

from pylab import *
sfs = figure(layout="constrained").subfigures(1, 2)
ax = sfs[0].add_subplot()
im = ax.imshow([[0, 1], [2, 3]])
ax.figure.colorbar(im, location="top")
ax = sfs[1].add_subplot()
im = ax.imshow([[0, 1], [2, 3]])
ax.figure.colorbar(im, cax=ax.inset_axes([0, 1.05, 1, 0.05]),
                   orientation="horizontal", ticklocation="top")
show()

Proposed solution

Add a location kwarg to the Colorbar constructor which sets both orientation and ticklocation, and is mutually exclusive with them.
... or at least better document the workaround.

Activity

  1. oscargus commented on Jun 14, 2022

    Member

    I assume that setting location should override orientation? Since orientation has a default non-None value. Or should one change the default value to None to be able to detect which value was set?

  2. anntzer commented on Jun 14, 2022

    ContributorAuthor

    Sure, I would apply the same logic as in make_axes (which is really encapsulated into _normalize_location_orientation).

  3. added this to the v3.7.0 milestone on Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL