Refactor line plot

This commit is contained in:
kojix2 2020-08-14 10:36:27 +09:00
parent 749ac8a091
commit 1f713d2a7b

View File

@ -173,18 +173,16 @@ module Uplot
def line(data, headers) def line(data, headers)
if data.size == 1 if data.size == 1
@params[:ylabel] ||= headers[0] if headers @params[:ylabel] ||= headers[0] if headers
y = data[0] y = data[0].map(&:to_f)
x = (1..y.size).to_a UnicodePlot.lineplot(y, **@params.compact)
else else
@params[:xlabel] ||= headers[0] if headers @params[:xlabel] ||= headers[0] if headers
@params[:ylabel] ||= headers[1] if headers @params[:ylabel] ||= headers[1] if headers
x = data[0] x = data[0].map(&:to_f)
y = data[1] y = data[1].map(&:to_f)
end
x = x.map(&:to_f)
y = y.map(&:to_f)
UnicodePlot.lineplot(x, y, **@params.compact) UnicodePlot.lineplot(x, y, **@params.compact)
end end
end
def get_method2(method1) def get_method2(method1)
(method1.to_s + '!').to_sym (method1.to_s + '!').to_sym