Thanks to visit codestin.com
Credit goes to github.com

Skip to content

"ValueError: All values in the dash list must be positive" if linewidth is set to zero in matplotlib 2.x.x #8821

Closed
@Awen0121

Description

@Awen0121

Bug report

In matplotlib 2.x.x, ValueError: All values in the dash list must be positive will be raised if linewidth is set to zero while it seems to work in matplotlib 1.5.x. No idea whether it is a bug or you intend to do so, but my macro don't work anymore because of this...

Code for reproduction

import matplotlib.pyplot as plt
x = [0, 1]
plt.plot(x, x, ls = '--', lw = 0)
plt.show()

Actual outcome

  • matplotlib 2.0.2
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1489, in __call__
    return self.func(*args)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 280, in resize
    self.show()
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 351, in draw
    FigureCanvasAgg.draw(self)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 464, in draw
    self.figure.draw(self.renderer)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/figure.py", line 1144, in draw
    renderer, self, dsu, self.suppressComposite)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 2426, in draw
    mimage._draw_list_compositing_images(renderer, self, dsu)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/lines.py", line 822, in draw
    drawFunc(renderer, gc, tpath, affine.frozen())
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/lines.py", line 1267, in _draw_lines
    self._lineFunc(renderer, gc, path, trans)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/lines.py", line 1297, in _draw_dashed
    gc.set_dashes(self._dashOffset, self._dashSeq)
  File "/home/chenyh/.local/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 1009, in set_dashes
    raise ValueError("All values in the dash list must be positive")
ValueError: All values in the dash list must be positive

Expected outcome

  • matplotlib1.5.1
    figure_1

Matplotlib version

  • Operating System: Tested on both Ubuntu 14.04.5 LTS / Mac OS X 10.12.5
  • Matplotlib Version: 2.0.2
  • Python Version: 2.7.13

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