Skip to content

[Bug]: Regression in dashes due to #22569 #22930

Closed

Description

@larsoner

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

Screenshot from 2022-04-28 12-03-38

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

96ddc67

Matplotlib Backend

QtAgg (PyQt6)

Python version

3.10.4

Jupyter version

No response

Installation

git checkout

Activity

  1. larsoner commented on Apr 28, 2022

    @larsoner
    ContributorAuthor

    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):

  2. timhoffm commented on Apr 28, 2022

    @timhoffm
    Member

    Sure, we should still accept (0, ()) and (0, []).

  3. larsoner commented on Apr 28, 2022

    @larsoner
    ContributorAuthor

    Okay, I can open a quick PR to fix this

  4. added this to the v3.6.0 milestone on Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions