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
This is potentially problematic for end-users. MNE-Python we know the default prop_cycle (and everyone seems to use it!) so make use of the fact that we know #7f7f7f is in there, remove it, and create a new cycle. Our code now breaks with:
self.color_list.remove("#7f7f7f")
ValueError: list.remove(x): x not in list
And yes we should make our check better (e.g., remove any color sufficiently close to the bad color, etc.) but it seems like a potential regression that this behavior has changed in any case. Feel free to close if not!
I'm inclined to close this as "won't fix" and suggest you use matplotlib.colors.to_hex() as a fix on your side. Or are there significant downstream issues for your users so that we need to consider deferring #20808. An alternative could also be to keep mpl.color_sequences["tab10"] as a list of the named colors and not already resolve them to RGB. This feels a bit nicer, but would be an equally strong breakage on the color_sequence side (though color_sequences are newer and probably less used compared to the default color cycle).
Totally! I made a fix already so all good at the MNE-Python end, I'm more bringing this up at the matplotlib end for the change in behavior of matplotlib.rcParams.get("axes.prop_cycle").by_key()["color"], I was surprised it changed from list[str] to list[tuple[float, float float]]. So more along the lines of what @rcomer is saying ☝
do we have a deprecation pathway for changing default rcParams?
No, unfortunately there is no reasonable migration path for changing a parameter, in particular not if the result is logically the same: We don't want to generally warn users when accessing the default property cycle and we can't tell whether the way the color is specified is relevant for them or not (it likely is not if they just feed the color back into matplotlib, but it can be if they operate on it explicitly as in this issue).
I was surprised it changed from list[str] to list[tuple[float, float float]].
Technically it is list[matplotlib.typing.ColorType but that's not formalized anywhere (and can't be because it's specific to dict value for the key "color").
Activity
timhoffm commentedon Apr 14, 2025
Relying on the hex notation is not safe. Note that users could have made their own color cycles and used the numerics (or more likely the named color
"tab:grey"https://matplotlib.org/stable/gallery/color/color_cycle_default.html#sphx-glr-gallery-color-color-cycle-default-py).I'm inclined to close this as "won't fix" and suggest you use
matplotlib.colors.to_hex()as a fix on your side. Or are there significant downstream issues for your users so that we need to consider deferring #20808. An alternative could also be to keepmpl.color_sequences["tab10"]as a list of the named colors and not already resolve them to RGB. This feels a bit nicer, but would be an equally strong breakage on the color_sequence side (though color_sequences are newer and probably less used compared to the default color cycle).rcomer commentedon Apr 14, 2025
@timhoffm do we have a deprecation pathway for changing default rcParams?
larsoner commentedon Apr 14, 2025
Totally! I made a fix already so all good at the MNE-Python end, I'm more bringing this up at the
matplotlibend for the change in behavior ofmatplotlib.rcParams.get("axes.prop_cycle").by_key()["color"], I was surprised it changed fromlist[str]tolist[tuple[float, float float]]. So more along the lines of what @rcomer is saying ☝QuLogic commentedon Apr 15, 2025
Or possibly
matplotlib.colors.same_color.timhoffm commentedon Apr 15, 2025
No, unfortunately there is no reasonable migration path for changing a parameter, in particular not if the result is logically the same: We don't want to generally warn users when accessing the default property cycle and we can't tell whether the way the color is specified is relevant for them or not (it likely is not if they just feed the color back into matplotlib, but it can be if they operate on it explicitly as in this issue).
timhoffm commentedon Apr 15, 2025
Technically it is
list[matplotlib.typing.ColorTypebut that's not formalized anywhere (and can't be because it's specific to dict value for the key "color").