Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed when calling add_artist function #5

Open
hukaidong opened this issue Aug 15, 2017 · 0 comments
Open

Failed when calling add_artist function #5

hukaidong opened this issue Aug 15, 2017 · 0 comments
Labels

Comments

@hukaidong
Copy link

hukaidong commented Aug 15, 2017

I was trying to migrate this script to ruby

import matplotlib as mpl
mpl.use("Qt5Agg")
from matplotlib import pyplot as plt
from matplotlib.patches import Rectangle as rec
fig, ax = plt.subplots(1)
ax.add_artist(rec([1,1],1,1))
ax.set_xlim(0,2)
ax.set_ylim(0,2)
fig.show()

with

require "matplotlib"
Matplotlib.use("Qt5Agg")
require 'matplotlib/pyplot'
plt = Matplotlib::Pyplot
def rec (*args) Matplotlib.patches.Rectangle(*args) end
fig, ax = plt.subplots(1)
ax.add_artist(rec([1,1],1,1))
ax.set_xlim(0,2)
ax.set_ylim(0,2)
fig.show

The python code runs well, but when I run the ruby code, I get following error messages

/var/lib/gems/2.3.0/gems/pycall-0.1.0.alpha.20170711/lib/pycall/pyobject_wrapper.rb:179:in `call': pytype(TypeError): TypeError("set_figure() missing 1 required positional argument: 'fig'",) (PyCall::PyError)
  File "/home/kaidonghu/.anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 1739, in add_artist
    self._set_artist_props(a)
  File "/home/kaidonghu/.anaconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 924, in _set_artist_props
    a.set_figure(self.figure)
	from /var/lib/gems/2.3.0/gems/pycall-0.1.0.alpha.20170711/lib/pycall/pyobject_wrapper.rb:34:in `block (2 levels) in wrap_class'
	from test.rb:7:in `<main>'

Is there anything I missed to let this happen? Thanks!

@mrkn mrkn added the bug label Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants