10000 quiver angles array UnboundLocalError: local variable 'lengths' referenced before assignment · Issue #9840 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
quiver angles array UnboundLocalError: local variable 'lengths' referenced before assignment  #9840
Closed
@neworderofjamie

Description

@neworderofjamie

Bug report

Trying to plot XY positions and associated (world-space) angles using quiver.
I would like the arrows to have a fixed length in axis-space but, what I think is the correct combination of options, does not correctly calculate the length variable in Quiver._make_verts.

Code for reproduction

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(10)
y = np.zeros_like(x)

u = np.ones_like(x)
v = np.ones_like(x)

angles = np.random.rand(*x.shape)
angles *= 360.0
angles -= 180.0

_, axis = plt.subplots()
axis.quiver(x, y, u, v, angles=angles, scale=1.0, scale_units="xy")
plt.show()

Actual outcome

Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1540, in __call__
    return self.func(*args)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 280, in resize
    self.show()
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 351, in draw
    FigureCanvasAgg.draw(self)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 464, in draw
    self.figure.draw(self.renderer)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/figure.py", line 1143, in draw
    renderer, self, dsu, self.suppressComposite)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 2409, in draw
    mimage._draw_list_compositing_images(renderer, self, dsu)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/image.py", line 139, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/artist.py", line 63, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/quiver.py", line 533, in draw
    verts = self._make_verts(self.U, self.V)
  File "/home/j/jk/jk421/.local/lib/python2.7/site-packages/matplotlib/quiver.py", line 628, in _make_verts
    a = lengths
UnboundLocalError: local variable 'lengths' referenced before assignment

Expected outcome
10 arrows with a fixed length in axis-space and random angles.

Matplotlib version

  • Operating system: Ubuntu 16.04 (LTS) x86_64
  • Matplotlib version: 2.0.0
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 2.7.12
  • Jupyter version (if applicable):
  • Other libraries:

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

      0