Add ylim to lines, scatter, density

This commit is contained in:
kojix2 2020-08-03 10:16:48 +09:00
parent 1dce48cd2c
commit 76f88eb55a

View File

@ -156,8 +156,10 @@ module Uplot
data.map! { |series| series.map(&:to_f) } data.map! { |series| series.map(&:to_f) }
@params[:name] ||= headers[1] if headers @params[:name] ||= headers[1] if headers
@params[:xlabel] ||=headers[0] 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.lineplot(data[0], data[1], **@params.compact)
2.upto(data.size - 1) do |i| 2.upto(data.size - 1) do |i|
p data[i]
UnicodePlot.lineplot!(plot, data[0], data[i], name: headers[i]) UnicodePlot.lineplot!(plot, data[0], data[i], name: headers[i])
end end
plot plot
@ -167,6 +169,7 @@ module Uplot
data.map! { |series| series.map(&:to_f) } data.map! { |series| series.map(&:to_f) }
@params[:name] ||= headers[1] if headers @params[:name] ||= headers[1] if headers
@params[:xlabel] ||=headers[0] if headers @params[:xlabel] ||=headers[0] if headers
@params[:ylim] ||= data[1..-1].flatten.minmax
plot = UnicodePlot.scatterplot(data[0], data[1], **@params.compact) plot = UnicodePlot.scatterplot(data[0], data[1], **@params.compact)
2.upto(data.size - 1) do |i| 2.upto(data.size - 1) do |i|
UnicodePlot.scatterplot!(plot, data[0], data[i], name: headers[i]) UnicodePlot.scatterplot!(plot, data[0], data[i], name: headers[i])
@ -178,6 +181,7 @@ module Uplot
data.map! { |series| series.map(&:to_f) } data.map! { |series| series.map(&:to_f) }
@params[:name] ||= headers[1] if headers @params[:name] ||= headers[1] if headers
@params[:xlabel] ||=headers[0] if headers @params[:xlabel] ||=headers[0] if headers
@params[:ylim] ||= data[1..-1].flatten.minmax
plot = UnicodePlot.densityplot(data[0], data[1], **@params.compact) plot = UnicodePlot.densityplot(data[0], data[1], **@params.compact)
2.upto(data.size - 1) do |i| 2.upto(data.size - 1) do |i|
UnicodePlot.densityplot!(plot, data[0], data[i], name: headers[i]) UnicodePlot.densityplot!(plot, data[0], data[i], name: headers[i])