class Numo::Gnuplot::NotePlot
Public Class Methods
new(&block)
click to toggle source
# File lib/numo/gnuplot.rb, line 31 def initialize(&block) if block.nil? raise ArgumentError,"block is needed" end @block = block end
Public Instance Methods
to_iruby()
click to toggle source
# File lib/numo/gnuplot.rb, line 38 def to_iruby require 'tempfile' tempfile_svg = Tempfile.open(['plot','.svg']) # output SVG to tmpfile gp = Gnuplot.default gp.reset gp.set terminal:'svg' gp.set output:tempfile_svg.path gp.instance_eval(&@block) gp.unset 'output' svg = File.read(tempfile_svg.path) tempfile_svg.close ["image/svg+xml",svg] end