From c9513e463fb43fcf75b7bed5b98c3f178f060672 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Tue, 19 Jan 2021 19:04:08 +0900 Subject: [PATCH] Add grid to parser --- lib/youplot/command/parser.rb | 38 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/youplot/command/parser.rb b/lib/youplot/command/parser.rb index 4c63925..c2c4386 100644 --- a/lib/youplot/command/parser.rb +++ b/lib/youplot/command/parser.rb @@ -171,6 +171,12 @@ module YouPlot end end + def sub_parser_add_grid + sub_parser.on_head('--[no-]grid', TrueClass, 'draws grid-lines at the origin') do |v| + params.grid = v + end + end + def create_sub_parser @sub_parser = create_default_parser sub_parser.banner = \ @@ -191,59 +197,61 @@ module YouPlot when :barplot, :bar sub_parser_add_symbol - sub_parser_add_xscale sub_parser.on_head('--fmt STR', String, 'xy : header is like x, y...', 'yx : header is like y, x...') do |v| @options[:fmt] = v end + sub_parser_add_xscale when :count, :c sub_parser_add_symbol sub_parser_add_xscale when :histogram, :hist - sub_parser.on_head('-n', '--nbins INT', Numeric, 'approximate number of bins') do |v| - params.nbins = v - end + sub_parser_add_symbol sub_parser.on_head('--closed STR', String, 'side of the intervals to be closed [left]') do |v| params.closed = v end - sub_parser_add_symbol + sub_parser.on_head('-n', '--nbins INT', Numeric, 'approximate number of bins') do |v| + params.nbins = v + end when :lineplot, :line sub_parser_add_canvas - sub_parser_add_xlim + sub_parser_add_grid sub_parser.on_head('--fmt STR', String, 'xy : header is like x, y...', 'yx : header is like y, x...') do |v| @options[:fmt] = v end + sub_parser_add_xlim when :lineplots, :lines sub_parser_add_canvas - sub_parser_add_xlim - sub_parser_add_ylim + sub_parser_add_grid sub_parser.on_head('--fmt STR', String, 'xyxy : header is like x1, y1, x2, y2, x3, y3...', 'xyy : header is like x, y1, y2, y2, y3...') do |v| @options[:fmt] = v end + sub_parser_add_ylim + sub_parser_add_xlim when :scatter, :s sub_parser_add_canvas - sub_parser_add_xlim - sub_parser_add_ylim + sub_parser_add_grid sub_parser.on_head('--fmt STR', String, 'xyxy : header is like x1, y1, x2, y2, x3, y3...', 'xyy : header is like x, y1, y2, y2, y3...') do |v| @options[:fmt] = v end + sub_parser_add_ylim + sub_parser_add_xlim when :density, :d - sub_parser.on_head('--grid', TrueClass) do |v| - params.grid = v - end - sub_parser_add_xlim - sub_parser_add_ylim + sub_parser_add_canvas + sub_parser_add_grid sub_parser.on('--fmt STR', String, 'xyxy : header is like x1, y1, x2, y2, x3, y3...', 'xyy : header is like x, y1, y2, y2, y3...') do |v| @options[:fmt] = v end + sub_parser_add_ylim + sub_parser_add_xlim when :boxplot, :box sub_parser_add_xlim