Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: set linestyle='dashed' raise error with quiver and legend #28298

Copy link
Copy link
Open
@quzhijing

Description

@quzhijing
Issue body actions

Bug summary

Issue description:
I am trying to print the linear arrow with dashed style, but there is error waring
"ValueError: At least one value in the dash list must be positive"

Code:
Part Code like following
plt.quiver(0, 0, v1[0], v1[1], angles='xy', scale_units='xy', scale=1, color='r', label='v1 (3, 4)', linestyle='solid')
plt.quiver(0, 0, v2[0], v2[1], angles='xy', scale_units='xy', scale=1, color='b', label='v2 (4, -3)', linestyle='solid')
v_sum = v1 + v2
plt.quiver(0, 0, v_sum[0], v_sum[1], angles='xy', scale_units='xy', scale=1, color='g', linestyle='dashed', linewidth=0, label='v1 + v2')

#I searched similar issue ticket: #8821 to set lw=0, it's still not work

enviroment:
my python version: Python 3.12.3
matplotlib version: 3.9.0

Code for reproduction

plt.quiver(0, 0, v1[0], v1[1], angles='xy', scale_units='xy', scale=1, color='r', label='v1 (3, 4)', linestyle='solid')
plt.quiver(0, 0, v2[0], v2[1], angles='xy', scale_units='xy', scale=1, color='b', label='v2 (4, -3)', linestyle='solid')
v_sum = v1 + v2
plt.quiver(0, 0, v_sum[0], v_sum[1], angles='xy', scale_units='xy', scale=1, color='g', linestyle='dashed', linewidth=0, label='v1 + v2')

Actual outcome

There is empty present
image

(mathenv) C:\WorkSpace\math>c:/WorkSpace/math/mathenv/Scripts/python.exe c:/WorkSpace/math/linearAnalog.py
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python312\Lib\tkinter_init_.py", line 1967, in call
return self.func(*args)
^^^^^^^^^^^^^^^^
File "C:\Python312\Lib\tkinter_init_.py", line 861, in callit
func(*args)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\backends_backend_tk.py", line 271, in idle_draw
self.draw()
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 10, in draw
super().draw()
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\backends\backend_agg.py", line 387, in draw
self.figure.draw(self.renderer)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\artist.py", line 95, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
return draw(artist, renderer)
^^^^^^^^^^^^^^^^^^^^^^
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\figure.py", line 3155, in draw
mimage._draw_list_compositing_images(
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\image.py", line 132, in _draw_list_compositing_images
a.draw(renderer)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
return draw(artist, renderer)
^^^^^^^^^^^^^^^^^^^^^^
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\axes_base.py", line 3109, in draw
mimage._draw_list_compositing_images(
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\image.py", line 132, in _draw_list_compositing_images
a.draw(renderer)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
return draw(artist, renderer)
^^^^^^^^^^^^^^^^^^^^^^
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\legend.py", line 777, in draw
self._legend_box.draw(renderer)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\artist.py", line 39, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\offsetbox.py", line 383, in draw
c.draw(renderer)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\artist.py", line 39, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\offsetbox.py", line 383, in draw
c.draw(renderer)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\artist.py", line 39, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\offsetbox.py", line 383, in draw
c.draw(renderer)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\artist.py", line 39, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\offsetbox.py", line 383, in draw
c.draw(renderer)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\artist.py", line 39, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\offsetbox.py", line 669, in draw
c.draw(renderer)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
return draw(artist, renderer)
^^^^^^^^^^^^^^^^^^^^^^
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\patches.py", line 632, in draw
self._draw_paths_with_artist_properties(
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\patches.py", line 594, in _draw_paths_with_artist_properties
gc.set_dashes(*self._dash_pattern)
File "c:\WorkSpace\math\mathenv\Lib\site-packages\matplotlib\backend_bases.py", line 924, in set_dashes
raise ValueError(
ValueError: At least one value in the dash list must be positive

Expected outcome

Expect the plt.quiver can print a dash arrow for the sum of two linear array

Additional information

No response

Operating system

No response

Matplotlib Version

3.9.0

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.