Skip to content

[MNT]: Colormaps odd behavior (1 != 1.0) #28198

@aaronshenhao

Description

@aaronshenhao

Summary

I encountered some unexpected behavior while usingn matplotlib.colormaps. Apparently, a_colormap(1) outputs the wrong result. The color it produces is indistinguishable from a_colormap(0), although it is slightly different. a_colormap(1.0) produces the correct result, but a_colormap(1.0) != a_colormap(1).

What is going on? It would be useful to clarify this in the docs.

Example

from matplotlib import colors, colormaps
import matplotlib.pyplot as plt

print(colors.to_hex(colormaps["binary"](0)), colors.to_hex(colormaps["binary"](1.0)))
print(colors.to_hex(colormaps["binary"](0)), colors.to_hex(colormaps["binary"](1)))

Output

#ffffff #000000
#ffffff #fefefe

Proposed fix

Improved documentation, or added consistency to make integer values work for the upper endpoint.

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

      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