Sha256: 21202a99b7ebdac6acddcc602d4fec3b043a79999cf4f7f585c598d2b06a8480

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require "matplotlib/version"
require 'pycall/import'

module Matplotlib
  @matplotlib = PyCall.import_module('matplotlib')
  PyCall.dir(@matplotlib).each do |name|
    obj = PyCall.getattr(@matplotlib, name)
    next unless obj.kind_of?(PyCall::PyObject) || obj.kind_of?(PyCall::PyObjectWrapper)
    next unless PyCall.callable?(obj)

    define_singleton_method(name) do |*args, **kwargs|
      obj.(*args, **kwargs)
    end
  end

  class << self
    def __pyobj__
      @matplotlib
    end

    def method_missing(name, *args, **kwargs)
      return super unless PyCall.hasattr?(@matplotlib, name)
      PyCall.getattr(@matplotlib, name)
    end
  end

  # FIXME: MacOSX backend is unavailable via pycall.
  #        I don't know why it is.
  if Matplotlib.get_backend() == 'MacOSX'
    Matplotlib.use('TkAgg')
  end

  class Error < StandardError
  end
end

require 'matplotlib/axis'
require 'matplotlib/axes'
require 'matplotlib/polar_axes'
require 'matplotlib/figure'
require 'matplotlib/spines'

PyCall.append_sys_path(File.expand_path('../matplotlib/python', __FILE__))

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
matplotlib-0.1.0.alpha.20170426 lib/matplotlib.rb
matplotlib-0.1.0.alpha.20170419a lib/matplotlib.rb