Try to add xlim option

This commit is contained in:
kojix2 2020-07-31 13:41:12 +09:00
parent 1fb369e26b
commit 7c0ab3ebdb

View File

@ -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