-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Labels
Description
Bug summary
The class method in the title is expecting a dictionary with values of type list, and this is not documented, nor it is intuitive.
Code for reproduction
import matplotlib.pyplot as plt
from matplotlib.widgets import RadioButtons
fig, ax=plt.subplots()
s = RadioButtons(
ax=ax,
labels=["0", "3", "4", "6"],
active=0,
)
s.set_label_props({'color': '0.7'})
plt.show()
Actual outcome
Traceback (most recent call last):
File "/home/doron/repos/lab-ion-trap-simulations/./t.py", line 14, in <module>
s.set_label_props({'color': '0.7'})
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/nix/store/zzzn0kgrcy13ckd7jwhjg2b3c2svkpbq-python3-3.13.5-env/lib/python3.13/site-packages/matplotlib/widgets.py", line 1720, in set_label_props
text.update(prop)
~~~~~~~~~~~^^^^^^
File "/nix/store/zzzn0kgrcy13ckd7jwhjg2b3c2svkpbq-python3-3.13.5-env/lib/python3.13/site-packages/matplotlib/text.py", line 205, in update
ret.extend(super().update(kwargs))
~~~~~~~~~~~~~~^^^^^^^^
File "/nix/store/zzzn0kgrcy13ckd7jwhjg2b3c2svkpbq-python3-3.13.5-env/lib/python3.13/site-packages/matplotlib/artist.py", line 1223, in update
return self._update_props(
~~~~~~~~~~~~~~~~~~^
props, "{cls.__name__!r} object has no property {prop_name!r}")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/zzzn0kgrcy13ckd7jwhjg2b3c2svkpbq-python3-3.13.5-env/lib/python3.13/site-packages/matplotlib/artist.py", line 1209, in _update_props
ret.append(func(v))
~~~~^^^
File "/nix/store/zzzn0kgrcy13ckd7jwhjg2b3c2svkpbq-python3-3.13.5-env/lib/python3.13/site-packages/matplotlib/text.py", line 1006, in set_color
mpl.colors._check_color_like(color=color)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/nix/store/zzzn0kgrcy13ckd7jwhjg2b3c2svkpbq-python3-3.13.5-env/lib/python3.13/site-packages/matplotlib/colors.py", line 249, in _check_color_like
raise ValueError(
...<6 lines>...
f"and pairs combining one of the above with an alpha value")
ValueError: '.' is not a valid value for color: supported inputs are (r, g, b) and (r, g, b, a) 0-1 float tuples; '#rrggbb', '#rrggbbaa', '#rgb', '#rgba' strings; named color strings; string reprs of 0-1 floats for grayscale values; 'C0', 'C1', ... strings for colors of the color cycle; and pairs combining one of the above with an alpha value
Expected outcome
No error, and this output:

Additional information
This seems to fix the issue:
s.set_label_props({'color': ['0.7']})
But it is very unexpected, and not intuitive IMO.
Operating system
NixOS
Matplotlib Version
3.10.3
Matplotlib Backend
qtagg
Python version
3.13.5
Jupyter version
Irrelevant
Installation
None