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
Using a cycler from matplotlib with a customised dashed linestyle for the property cycle in Axes.set_prop_cycle throws a ValueError (see below). Importing cycler from cycler works as expected.
Code for reproduction
importmatplotlib.pyplotaspltfrommatplotlibimportrcParamsfrommatplotlibimportcycler# from cycler import cycler works finecc=cycler('linestyle', [(0,(3,1)), '-'])
fig=plt.figure()
ax=fig.add_subplot(221)
ax.set_prop_cycle(cc)
ax.plot(range(10))
Actual outcome
Traceback (most recent call last):
File "err.py", line 10, in <module>
ax.plot(range(10))
File "/usr/local/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 1665, in plot
lines = [*self._get_lines(*args, data=data, **kwargs)]
File "/usr/local/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 225, in __call__
yield from self._plot_args(this, kwargs)
File "/usr/local/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 405, in _plot_args
seg = func(x[:, j % ncx], y[:, j % ncy], kw, kwargs)
File "/usr/local/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 312, in _makeline
seg = mlines.Line2D(x, y, **kw)
File "/usr/local/lib/python3.7/site-packages/matplotlib/lines.py", line 377, in __init__
self.set_linestyle(linestyle)
File "/usr/local/lib/python3.7/site-packages/matplotlib/lines.py", line 1186, in set_linestyle
cbook._check_in_list([*self._lineStyles, *ls_mapper_r], ls=ls)
File "/usr/local/lib/python3.7/site-packages/matplotlib/cbook/__init__.py", line 2170, in _check_in_list
.format(v, k, ', '.join(map(repr, values))))
ValueError: '(0, (3, 1))' is not a valid value for ls; supported values are '-', '--', '-.', ':', 'None', ' ', '', 'solid', 'dashed', 'dashdot', 'dotted'
Expected outcome
I would expect matplotlib.cycler to work the same as cycler.cycler. However, in this case matplotlib.cycler throws a ValueError.
Bug report
Bug summary
Using a cycler from matplotlib with a customised dashed linestyle for the property cycle in Axes.set_prop_cycle throws a ValueError (see below). Importing cycler from cycler works as expected.
Code for reproduction
Actual outcome
Expected outcome
I would expect matplotlib.cycler to work the same as cycler.cycler. However, in this case matplotlib.cycler throws a ValueError.
Matplotlib version
print(matplotlib.get_backend())
): MacOSXmatplotlib installed via pip
The text was updated successfully, but these errors were encountered: