From 7c0ab3ebdb70871e26e139a407cc79e13e6e428e Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Fri, 31 Jul 2020 13:41:12 +0900 Subject: [PATCH] Try to add xlim option --- lib/uplot/command.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/uplot/command.rb b/lib/uplot/command.rb index 2112b4c..6732b05 100644 --- a/lib/uplot/command.rb +++ b/lib/uplot/command.rb @@ -32,7 +32,8 @@ module Uplot main_parser = create_parser parsers = Hash.new { |h, k| h[k] = create_parser } parsers['hist'] .on('--nbins VAL', Numeric) { |v| @params[:nbins] = v } - parsers['histogram'] = parsers['hist'] + parsers['histogram'] = parsers['hist'] + parsers['line'] .on('-x', '--xlim VAL', String) { |v| @params[:xlim] = get_lim(v) } parsers['lineplot'] = parsers['line'] parsers['lineplots'] = parsers['lines'] parsers['scatterplot'] = parsers['scatter'] @@ -108,6 +109,10 @@ module Uplot UnicodePlot.histogram(series, **@params.compact) end + def get_lim(str) + str.split(/-|:|\.\./)[0..1].map(&:to_f) + end + def line(data, headers) if data.size == 1 @params[:name] ||= headers[0] if headers