lava / matplotlib-cpp

Extremely simple yet powerful header-only C++ plotting library built on the popular matplotlib
MIT License
4.38k stars 1.13k forks source link

Setting the scale parameter in quiver function throws a TypeError #215

Open h4k1m0u opened 4 years ago

h4k1m0u commented 4 years ago

I'm unable to set the scale parameter in the quiver function to resize the vector plotted. This parameter is normally passed together with other kwargs parameters, however matplotlib's python library seems to be expecting a numeric value while the matplotlibcpp's std::map has both the key and the value as std::string

The code below:

const std::map<std::string, std::string> kwargs_arrow{{"scale", "1"}};
matplotlibcpp::quiver(x, y, u, v, kwargs_arrow); 

throws a TypeError:

Traceback (most recent call last):
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 498, in _draw_idle
    self.draw()
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 393, in draw
    self.figure.draw(self.renderer)
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/figure.py", line 1736, in draw
    renderer, self, artists, self.suppressComposite)
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/image.py", line 137, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2630, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/image.py", line 137, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/quiver.py", line 589, in draw
    verts = self._make_verts(self.U, self.V, self.angles)
  File "/home/hakim/.local/lib/python3.6/site-packages/matplotlib/quiver.py", line 716, in _make_verts
    length = a * (widthu_per_lenu / (self.scale * self.width))
TypeError: can't multiply sequence by non-int of type 'numpy.float64'
josemoragaposselt commented 2 years ago

Hey, did you solve the problem? I have the same output and I've tried all :(