Skip to content

[Bug]: colorbar axes title clobbers extend arrow #23041

@nspies-celsiustx

Description

@nspies-celsiustx

Bug summary

Adding a title to a colorbar works fine in most cases, but misplaces the title text when using extend=max as argument to plt.colorbar().

Code for reproduction

fig, ax = plt.subplots(figsize=(6,6))
x, y, z = [np.random.random(100) for i in range(3)]

scatter = ax.scatter(x, y, c=z)
cbar = plt.colorbar(scatter, extend="max", ax=ax)
cbar.ax.set_title("asdf")

Actual outcome

image

Expected outcome

I would expect the title text to be above the colorbar including the arrow. This is what happens when running the above code but without extend="max":

fig, ax = plt.subplots(figsize=(6,6))
x, y, z = [np.random.random(100) for i in range(3)]

scatter = ax.scatter(x, y, c=z)
cbar = plt.colorbar(scatter, ax=ax)
cbar.ax.set_title("asdf")

image

Additional information

Aesthetically, this is less of an issue with smaller figure sizes but it should generally place the text in the right place irrespective of figure dimensions.

Operating system

No response

Matplotlib Version

3.5.1

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy