colormaps don't have getters for under, over, bad colors. · Issue #16075 · matplotlib/matplotlib · GitHub
Skip to content

colormaps don't have getters for under, over, bad colors. #16075

Description

@pharshalp

Bug report

Bug summary
colormaps don't have getters for under, over, bad colors (although the corresponding setters exist).
I am writing a function that accepts a colormap as an argument. I want to ensure that the colormap passed to the function has the same color for the "bad" and "under" conditions. The only way around this is to access "private" attributes cmap._rgba_under, cmap._rgba_bad as shown below.

Code for reproduction

cmap = plt.get_cmap('cividis')
cmap.set_bad('k')
cmap.set_under('k')

assert cmap._rgba_bad == cmap._rgba_under

If adding getters (for under, over, bad colors) for the colormaps sounds like a good improvement, i would be interested in submitting a PR.

Actual outcome

# If applicable, paste the console output here
#
#

Expected outcome

Matplotlib version

  • Operating system:
  • Matplotlib version:
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version:
  • Jupyter version (if applicable):
  • Other libraries:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions