Thanks to visit codestin.com
Credit goes to github.com

Skip to content

IRuby integration is broken #18

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

Closed
mrkn opened this issue Feb 11, 2023 · 5 comments
Closed

IRuby integration is broken #18

mrkn opened this issue Feb 11, 2023 · 5 comments
Assignees
Labels

Comments

@mrkn
Copy link
Member

mrkn commented Feb 11, 2023

Using with matplotlib 3.6.0, the following error occurs in Matplotlib::IRuby.activate.

PyCall::PyError: <class 'AttributeError'>: module 'matplotlib_rb.backend_inline' has no attribute 'FigureCanvas'
  File "/opt/conda/lib/python3.10/site-packages/matplotlib/pyplot.py", line 266, in switch_backend
    canvas_class = backend_mod.FigureCanvas

/home/jovyan/.local/share/gem/ruby/3.1.0/gems/matplotlib-1.2.0/lib/matplotlib/iruby.rb:201:in `switch_backend'
/home/jovyan/.local/share/gem/ruby/3.1.0/gems/matplotlib-1.2.0/lib/matplotlib/iruby.rb:201:in `activate_matplotlib'
/home/jovyan/.local/share/gem/ruby/3.1.0/gems/matplotlib-1.2.0/lib/matplotlib/iruby.rb:152:in `enable_matplotlib'
/home/jovyan/.local/share/gem/ruby/3.1.0/gems/matplotlib-1.2.0/lib/matplotlib/iruby.rb:111:in `activate'
(irb):1:in `<top (required)>'
@kojix2
Copy link
Member

kojix2 commented Mar 10, 2023

Here is a minimal reproducible example:

require "iruby"
require "matplotlib/iruby"

# `activate_matplotlib` is a private method
Matplotlib::IRuby.send("activate_matplotlib", "module://matplotlib_rb.backend_inline")

In my environment, replacing FigureCanvasAgg with FigureCanvas worked.

https://github.com/mrkn/matplotlib.rb/blob/3fd731b2c5cd4897f3f5e21105bad36627f8fa88/lib/matplotlib/python/matplotlib_rb/backend_inline.py#L1

@mrkn
Copy link
Member Author

mrkn commented Mar 10, 2023

@kojix2 Thank you for the information.

@mrkn
Copy link
Member Author

mrkn commented Mar 14, 2023

I confirmed that matplotlib/matplotlib#23090 is the reason. It changed the pyplot.switch_backend behavior to refer to FigureCanvas.

@mrkn
Copy link
Member Author

mrkn commented Mar 16, 2023

Fixed by 1b7328e

@mrkn mrkn closed this as completed Mar 16, 2023
@kozo2
Copy link

kozo2 commented Mar 18, 2023

Thanks for 1b7328e .
Now I have succeeded in embedding the matplotlib.rb image in the ipynb output cell.
image

That is what I needed to do! Thanks!

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

3 participants