Module: Matplotlib::IRuby::Helper

Defined in:
lib/matplotlib/iruby.rb

Constant Summary collapse

BytesIO =
PyCall.import_module('io').BytesIO

Instance Method Summary collapse

Instance Method Details

#register_formatsObject



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/matplotlib/iruby.rb', line 93

def register_formats
  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 = BytesIO.new
      fig.canvas.print_figure(io, format: format, bbox_inches: 'tight')
      io.getvalue
    end
  end
end