You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When invoking a LinearSegmentedColormap object as a function, the output can differ based on whether you pass an integer or a float.
For example, in the code snippet below, cmap(1) returns a completely different result than cmap(1.0). While this behavior might be expected given how the colormap is implemented, it feels unintuitive.
IMO the provided reprex demonstrates the issue clearly, but please let me know if more details are needed.
Bug summary
When invoking a
LinearSegmentedColormap
object as a function, the output can differ based on whether you pass an integer or a float.For example, in the code snippet below,
cmap(1)
returns a completely different result thancmap(1.0)
. While this behavior might be expected given how the colormap is implemented, it feels unintuitive.IMO the provided reprex demonstrates the issue clearly, but please let me know if more details are needed.
Code for reproduction
Actual outcome
cmap(0): (np.float64(1.0), np.float64(0.0), np.float64(0.0), np.float64(1.0))
(red)cmap(1): (np.float64(0.996078431372549), np.float64(0.0), np.float64(0.00392156862745098), np.float64(1.0))
(red)cmap(1.0): (np.float64(0.0), np.float64(0.0), np.float64(1.0), np.float64(1.0))
(blue)Expected outcome
cmap(0): (np.float64(1.0), np.float64(0.0), np.float64(0.0), np.float64(1.0))
(red)cmap(1): (np.float64(0.0), np.float64(0.0), np.float64(1.0), np.float64(1.0))
(blue)cmap(1.0): (np.float64(0.0), np.float64(0.0), np.float64(1.0), np.float64(1.0))
(blue)Additional information
No response
Operating system
MacOS Sonoma 14.6.1
Matplotlib Version
3.10.0
Matplotlib Backend
module://positron_ipykernel.matplotlib_backend
Python version
Python 3.13.1
Jupyter version
/
Installation
pip
The text was updated successfully, but these errors were encountered: