Fix xlim and ylim

This commit is contained in:
kojix2
2021-01-19 19:23:44 +09:00
parent c9513e463f
commit a8ce96888e
4 changed files with 51 additions and 49 deletions

View File

@@ -90,6 +90,7 @@ module YouPlot
params.name ||= headers[1]
params.xlabel ||= headers[0]
end
params.xlim ||= series[0].flatten.minmax # why need?
params.ylim ||= series[1..-1].flatten.minmax # why need?
plot = UnicodePlot.public_send(method1, series[0], series[1], **params.to_hc)
2.upto(series.size - 1) do |i|
@@ -103,13 +104,14 @@ module YouPlot
series = data.series
method2 = get_method2(method1)
series.map! { |s| s.map(&:to_f) }
series = series.each_slice(2).to_a
series2 = series.each_slice(2).to_a
series = nil
params.name ||= headers[0] if headers
params.xlim = series.map(&:first).flatten.minmax # why need?
params.ylim = series.map(&:last).flatten.minmax # why need?
params.xlim ||= series2.map(&:first).flatten.minmax # why need?
params.ylim ||= series2.map(&:last).flatten.minmax # why need?
x1, y1 = series.shift
plot = UnicodePlot.public_send(method1, x1, y1, **params.to_hc)
series.each_with_index do |(xi, yi), i|
series2.each_with_index do |(xi, yi), i|
UnicodePlot.public_send(method2, plot, xi, yi, name: headers&.[]((i + 1) * 2))
end
plot