Sha256: c3579c7ea95fe5dc0c1790d9f98fee925cb880ee42301ab63e6b99808974d38e
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
require 'pycall' module Matplotlib module IRuby AGG_FORMATS = { "image/png" => "png", "application/pdf" => "pdf", "application/eps" => "eps", "image/eps" => "eps", "application/postscript" => "ps", "image/svg+xml" => "svg" } module Helper def register_formats bytes_io = PyCall.import_module('io').BytesIO type { Figure } AGG_FORMATS.each do |mime, format| format mime do |fig| unless fig.canvas.get_supported_filetypes.().has_key?(format) raise Error, "Unable to display a figure in #{format} format" end io = bytes_io.() fig.canvas.print_figure.(io, format: format, bbox_inches: 'tight') io.getvalue.() end end end end class << self # NOTE: This method is translated from `IPython.core.activate_matplotlib` function. def activate(gui=:inline) require 'matplotlib/pyplot' end end end end ::IRuby::Display::Registry.module_eval do extend Matplotlib::IRuby::Helper register_formats end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
matplotlib-0.1.0.alpha.20170302 | lib/matplotlib/iruby.rb |