-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[MNT]: ListedColormap inconsistencies #28763
Copy link
Copy link
Closed
Labels
API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …Consistency of the matplotlib API, including naming, behavior, defaults, …Documentation: APIfiles in lib/ and doc/apifiles in lib/ and doc/apiMaintenancetopic: color/color & colormaps
Milestone
Metadata
Metadata
Assignees
Labels
API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …Consistency of the matplotlib API, including naming, behavior, defaults, …Documentation: APIfiles in lib/ and doc/apifiles in lib/ and doc/apiMaintenancetopic: color/color & colormaps
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
The documentation to
ListedColormapstates that the input should be a list or arraymatplotlib/lib/matplotlib/colors.py
Lines 1175 to 1177 in b01462c
However, when specifying N,
strandfloatare also supported (if one use the source code)matplotlib/lib/matplotlib/colors.py
Lines 1199 to 1214 in b01462c
This means that, e.g.,
ListedColormap("#aabbcc", N=1)works, butListedColormap("#aabbcc")does not (there will be weird errors later, likeN=7for the latter). Given that there ismonochromeattribute and the documentation of N, one may expect the latter to work as well (if the earlier works). Also,ListedColormap(["#aabbcc"])will not set themonochromeattribute correctly.Proposed fix
I think there are three(?) possible solutions:
ListedColormap(0.3, N=7)thanListedColormap([0.3]*7)or at least require slightly less Python knowledge)Bonus: document the
colorandmonochromeattributes