diff --git a/lib/uplot/command.rb b/lib/uplot/command.rb index ad2b846..b3172a7 100644 --- a/lib/uplot/command.rb +++ b/lib/uplot/command.rb @@ -158,40 +158,34 @@ module Uplot UnicodePlot.lineplot(x, y, **@params.compact) end - def lines(data, headers) + def x1_y1_y2_style(data, headers, call1, call2) # Fix method name data.map! { |series| series.map(&:to_f) } @params[:name] ||= headers[1] if headers @params[:xlabel] ||= headers[0] if headers @params[:ylim] ||= data[1..-1].flatten.minmax - plot = UnicodePlot.lineplot(data[0], data[1], **@params.compact) + plot = UnicodePlot.public_send(call1, data[0], data[1], **@params.compact) 2.upto(data.size - 1) do |i| - UnicodePlot.lineplot!(plot, data[0], data[i], name: headers[i]) + UnicodePlot.public_send(call2, plot, data[0], data[i], name: headers[i]) end plot end + def lines(data, headers) + if true # x1_y1_y2_style + x1_y1_y2_style(data, headers, :lineplot, :lineplot!) + end + end + def scatter(data, headers) - data.map! { |series| series.map(&:to_f) } - @params[:name] ||= headers[1] if headers - @params[:xlabel] ||= headers[0] if headers - @params[:ylim] ||= data[1..-1].flatten.minmax - plot = UnicodePlot.scatterplot(data[0], data[1], **@params.compact) - 2.upto(data.size - 1) do |i| - UnicodePlot.scatterplot!(plot, data[0], data[i], name: headers[i]) + if true # x1_y1_y2_style + x1_y1_y2_style(data, headers, :scatterplot, :scatterplot!) end - plot end def density(data, headers) - data.map! { |series| series.map(&:to_f) } - @params[:name] ||= headers[1] if headers - @params[:xlabel] ||= headers[0] if headers - @params[:ylim] ||= data[1..-1].flatten.minmax - plot = UnicodePlot.densityplot(data[0], data[1], **@params.compact) - 2.upto(data.size - 1) do |i| - UnicodePlot.densityplot!(plot, data[0], data[i], name: headers[i]) + if true # x1_y1_y2_style + x1_y1_y2_style(data, headers, :densityplot, :densityplot!) end - plot end def boxplot(data, headers)