Module: Simpler::Plot
- Included in:
- Simpler
- Defined in:
- lib/simpler/plot.rb
Class Method Summary collapse
-
.filename_to_plottype(name) ⇒ Object
returns it as a symbol, currently recognizes pdf, png, svg.
Instance Method Summary collapse
Class Method Details
.filename_to_plottype(name) ⇒ Object
returns it as a symbol, currently recognizes pdf, png, svg
6 7 8 |
# File 'lib/simpler/plot.rb', line 6 def self.filename_to_plottype(name) name.match(/\.([^\.]+)$/)[1].downcase.to_sym end |
Instance Method Details
#plot(file_w_extension, opts = {}, &block) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/simpler/plot.rb', line 10 def plot(file_w_extension, opts={}, &block) device = Simpler::Plot.filename_to_plottype(file_w_extension) opts_as_ropts = opts.map {|k,v| "#{k}=#{Simpler.r_format(v)}"} string = "#{device}(#{file_w_extension.inspect}, #{opts_as_ropts.join(', ')})\n" string << block.call << "\n" string << "dev.off()\n" string end |