| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
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')(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
Expect the plt.quiver can print a dash arrow for the sum of two linear array
No response
No response
3.9.0
No response
No response
No response
None
| Back | FazBrowse Home | New Git URL |
Activity
rcomer commented on May 26, 2024
Hello @quzhijing thanks for the report. Please could you provide a complete code example that we can run to reproduce the problem?
quzhijing commented on May 30, 2024
@rcomer my complete code:
tacaswell commented on May 30, 2024
A minimal reproducer:
setting lw to be >0 or not showing the legend fixes the problem. Something is going wrong in generating the legend entry, I think because it is grabbing a post-scaled version of the dash pattern.
quzhijing commented on May 31, 2024
@tacaswell Thanks, it's fixed after remote legend() show, So would we can expect to fix in newer version?
QuLogic commented on Jun 28, 2024
quiver produces a Quiver, which is a PolyCollection, so the legend handler for that copies the linestyle as:
matplotlib/lib/matplotlib/legend_handler.py
Line 801 in 74c7f9a
The semantics between the setter and getter are a bit confused, so this is somewhat related to #23056, though unfortunately, that PR does not fix this bug.
5 remaining items
QuLogic commented on Sep 10, 2025
QuLogic commented on Mar 20, 2026
Fixed by #31307.