Repository navigation
Closed
Milestone
Description
Bug summary
Previously working plotting code has broken. It fails on 96ddc67 / #22569 but passes on the parent daaa1ed.
Code for reproduction
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([0, 1], [0, 1], ls=(0, ()))
plt.show()Actual outcome
No line shown, error while drawing
File "/home/larsoner/python/matplotlib/lib/matplotlib/backends/backend_qt.py", line 479, in _draw_idle
self.draw()
File "/home/larsoner/python/matplotlib/lib/matplotlib/backends/backend_agg.py", line 424, in draw
self.figure.draw(self.renderer)
File "/home/larsoner/python/matplotlib/lib/matplotlib/artist.py", line 73, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
File "/home/larsoner/python/matplotlib/lib/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer)
File "/home/larsoner/python/matplotlib/lib/matplotlib/figure.py", line 2860, in draw
mimage._draw_list_compositing_images(
File "/home/larsoner/python/matplotlib/lib/matplotlib/image.py", line 131, in _draw_list_compositing_images
a.draw(renderer)
File "/home/larsoner/python/matplotlib/lib/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer)
File "/home/larsoner/python/matplotlib/lib/matplotlib/axes/_base.py", line 3101, in draw
mimage._draw_list_compositing_images(
File "/home/larsoner/python/matplotlib/lib/matplotlib/image.py", line 131, in _draw_list_compositing_images
a.draw(renderer)
File "/home/larsoner/python/matplotlib/lib/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer)
File "/home/larsoner/python/matplotlib/lib/matplotlib/lines.py", line 772, in draw
gc.set_dashes(*self._dash_pattern)
File "/home/larsoner/python/matplotlib/lib/matplotlib/backend_bases.py", line 930, in set_dashes
raise ValueError(
ValueError: At least one value in the dash list must be positive
Expected outcome
Line shown
Additional information
Maybe we use a weird/bad/incorrect convention in our code by creating ls=(0, ()) and we can certainly work around it/fix it, but it used to work at least! At a minimum it might be nice to raise a nicer error if possible...
Operating system
Ubuntu 22.04
Matplotlib Version
Matplotlib Backend
QtAgg (PyQt6)
Python version
3.10.4
Jupyter version
No response
Installation
git checkout
Metadata
Metadata
Assignees
Labels
No labels

Activity
larsoner commentedon Apr 28, 2022
It looks like internally matplotlib uses
'solid': (0, None)which is fine, I can switch our code to that -- but it seems like for backward compat supporting'solid': (0, ())as an alias would make sense since it used to be that way in official examples (here from 2.x):matplotlib/examples/lines_bars_and_markers/linestyles.py
Line 14 in 908d23d
timhoffm commentedon Apr 28, 2022
Sure, we should still accept
(0, ())and(0, []).larsoner commentedon Apr 28, 2022
Okay, I can open a quick PR to fix this