lib/rbbt/util/R/plot.rb in rbbt-util-5.19.35 vs lib/rbbt/util/R/plot.rb in rbbt-util-5.19.36

- old
+ new

@@ -8,10 +8,18 @@ options = options.dup sources = [:plot, Rbbt.share.Rlib["svg.R"].find(:lib), options[:source]].flatten.compact options.delete :source + fast = options[:fast] + + if fast + save_method = "rbbt.SVG.save.fast" + else + save_method = "rbbt.SVG.save" + end + if data data.each do |k,v| v = Array === v ? v : [v] next if v == "NA" or v.nil? or v.include? "NA" or v.include? nil values = v @@ -46,11 +54,11 @@ TmpFile.with_file nil, true, :extension => 'svg' do |tmpfile| data.R <<-EOF, sources, options plot = { #{script} } - rbbt.SVG.save('#{tmpfile}', plot, width = #{R.ruby2R width}, height = #{R.ruby2R height}) + #{save_method}('#{tmpfile}', plot, width = #{R.ruby2R width}, height = #{R.ruby2R height}) data = NULL EOF Open.read(tmpfile).gsub(/(glyph\d+-\d+)/, '\1-' + File.basename(tmpfile)) @@ -59,10 +67,10 @@ TmpFile.with_file nil, true, :extension => 'svg' do |tmpfile| R.run <<-EOF, sources, options plot = { #{script} } - rbbt.SVG.save('#{tmpfile}', plot, width = #{R.ruby2R width}, height = #{R.ruby2R height}) + #{save_method}('#{tmpfile}', plot, width = #{R.ruby2R width}, height = #{R.ruby2R height}) data = NULL EOF Open.read(tmpfile).gsub(/(glyph\d+-\d+)/, '\1-' + File.basename(tmpfile)) end end