Skip to content

feat: plt.show #12

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/matplotlib/iruby.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'matplotlib'
require 'matplotlib/pyplot'

module Matplotlib
module IRuby
Expand Down Expand Up @@ -188,13 +189,11 @@ def find_gui_and_backend(gui=nil, gui_select=nil)
#
# @param [String, Symbol] backend a name of matplotlib backend
def activate_matplotlib(backend)
require 'matplotlib'
Matplotlib.interactive(true)

backend = backend.to_s
Matplotlib.rcParams['backend'] = backend

require 'matplotlib/pyplot'
Matplotlib::Pyplot.switch_backend(backend)

# TODO: should support wrapping python function
Expand Down Expand Up @@ -254,6 +253,21 @@ def show_figures(close=false)
end
end
end

Pyplot.module_eval do
def self.show(close=true)
_pylab_helpers = PyCall.import_module('matplotlib._pylab_helpers')
gcf = _pylab_helpers.Gcf
gcf.get_all_fig_managers.each do |fig_manager|
::IRuby::display(fig_manager.canvas.figure)
end
return
ensure
if close && gcf.get_all_fig_managers.length > 0
close('all')
end
end
end
end

::IRuby::Display::Registry.module_eval do
Expand Down