-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Markers with numeric name like CARETLEFT cannot be specified using a cycler #27596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like the validator for the `marker` property is a stringlist
validator, so it is trying to coerce things into strings. Probably should
update the validator.
…On Wed, Jan 3, 2024 at 1:06 PM castilma ***@***.***> wrote:
Bug summary
I want to cycle between multiple markerstyles, including those with a
numeric value like CARETRIGHT as documented here
<https://matplotlib.org/stable/api/markers_api.html#module-matplotlib.markers>,
but I get an exception if I add one of those.
Code for reproduction
#!/usr/bin/env python3
from cycler import cyclerimport matplotlib.pyplot as pltimport matplotlib.markers as mk
cycle = cycler(marker=["+",mk.CARETRIGHT])
t=[0,1]y=[5,6]
plt.rc('axes', prop_cycle=cycle)plt.plot(t,y)plt.show()
Actual outcome
Traceback (most recent call last):
File "/home/mcd/bugs/bug-cycler.py", line 11, in <module>
plt.rc('axes', prop_cycle=cycle)
File "/usr/lib/python3.11/site-packages/matplotlib/pyplot.py", line 670, in rc
matplotlib.rc(group, **kwargs)
File "/usr/lib/python3.11/site-packages/matplotlib/__init__.py", line 1062, in rc
rcParams[key] = v
~~~~~~~~^^^^^
File "/usr/lib/python3.11/site-packages/matplotlib/__init__.py", line 734, in __setitem__
raise ValueError(f"Key {key}: {ve}") from None
ValueError: Key axes.prop_cycle: Could not convert 5 to str
Expected outcome
A plot using CARETLEFT as marker.
Additional information
This seems like it has to do with the fact, that some markers are referred
to by number and not by a string like "+".
I don't know whether the problem is in matplotlib, cycler or the
combination of both.
Operating system
Artix Linux
Matplotlib Version
3.8.1
Matplotlib Backend
GTK4Agg
Python version
Python 3.11.6
Jupyter version
*No response*
Installation
Linux package manager
—
Reply to this email directly, view it on GitHub
<#27596>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACHF6ELTISA2WV6D5ACXBLYMWM3TAVCNFSM6AAAAABBLZNEFCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3DINBUGUZTKOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
More specifically matplotlib/lib/matplotlib/rcsetup.py Line 648 in 8703dc5
In [13]: plt.rcParams['lines.marker'] = mk.CARETRIGHT
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[13], line 1
----> 1 plt.rcParams['lines.marker'] = mk.CARETRIGHT
File /usr/lib/python3.11/site-packages/matplotlib/__init__.py:734, in RcParams.__setitem__(self, key, val)
732 cval = self.validate[key](val)
733 except ValueError as ve:
--> 734 raise ValueError(f"Key {key}: {ve}") from None
735 self._set(key, cval)
736 except KeyError as err:
ValueError: Key lines.marker: Could not convert 5 to str is a simpler way exercise the same issue. |
Good first issue - notes for new contributorsThis issue is suited to new contributors because it does not require understanding of the Matplotlib internals. To get started, please see our contributing guide. We do not assign issues. Check the Development section in the sidebar for linked pull requests (PRs). If there are none, feel free to start working on it. If there is an open PR, please collaborate on the work by reviewing it rather than duplicating it in a competing PR. If something is unclear, please reach out on any of our communication channels. |
Steps:
Good first issue because this is very narrowly scoped, but medium because there is some meta-programming in the validator code. Some thought will need to be given to writing a validator that works for both "live" objects and for strings coming from reading and .matplotlibrc. |
The problem might exist in several places such as
https://github.com/matplotlib/matplotlib/blob/8703dc5682d3655258d8917c1f8ef63cb1576dbb/lib/matplotlib/rcsetup.py#L911
…On Wed, Jan 3, 2024 at 1:38 PM Thomas A Caswell ***@***.***> wrote:
Steps:
- update the marker validator to accept all valid marker
specifications (atleast the integers, maybe the path and Marker
classes as well)
- add a test
- add a whats new (if extended past integers)
Good first issue because this is very narrowly scoped, but medium because
there is some meta-programming in the validator code. Some thought will
need to be given to writing a validator that works for both "live" objects
and for strings coming from reading and .matplotlibrc.
—
Reply to this email directly, view it on GitHub
<#27596 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACHF6GY7VSBKB7VZ77OGN3YMWQTFAVCNFSM6AAAAABBLZNEFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZVHAYDCOJXGE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Bug summary
I want to cycle between multiple markerstyles, including those with a numeric value like CARETRIGHT as documented here, but I get an exception if I add one of those.
Code for reproduction
Actual outcome
Expected outcome
A plot using CARETLEFT as marker.
Additional information
This seems like it has to do with the fact, that some markers are referred to by number and not by a string like "+".
I don't know whether the problem is in matplotlib, cycler or the combination of both.
Operating system
Artix Linux
Matplotlib Version
3.8.1
Matplotlib Backend
GTK4Agg
Python version
Python 3.11.6
Jupyter version
No response
Installation
Linux package manager
The text was updated successfully, but these errors were encountered: