youplot 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9b1c58784cb37da38b1c2bb24ed86961a8d7ddded67899027f9ed725ece7ea8
4
- data.tar.gz: 1f6050c3707ecaa29997ee1af65b440ba016f0eacb47d4dc9c38a15ac59afe9a
3
+ metadata.gz: ff7e21952a560421314ae80fc894a8c1321d27ad985f50d2cdc53f8b3306a5ba
4
+ data.tar.gz: 5229cb0a38b73477ab91570dd0d04bf646c66d511fb6d5c8a12c09d64a08d1cf
5
5
  SHA512:
6
- metadata.gz: 5d62aeed65f6a4692f115453b085cb926d54a8efe184e7e39250a720235f8d13ecf8ec2026099ae2d6a3ab17385e607a9281fff1b12e81914314c991bf471ca4
7
- data.tar.gz: 1e3ad16f26c8287385fdee2a4f13626b369a58c63f2d488678b02bdc15dfb7e22a8b8ed0f31c1d6324537c59aa86c4367187f01e6080f6bf51f3bedade3905f4
6
+ metadata.gz: d8d28d4118af6be5d7b115a3341e2bc066821718d0367286c2dbb2d49f364ac241af1d75f8c0466f91761e7a1c1ccdab4693010f41389c2703a25a3b9b83c8a2
7
+ data.tar.gz: ccc0b88ff329b9f002cb089f07ddfd9e3be8eed1a63a6c609df018efb1b25f3a92ff640ae22413e3271d051799cc009a090d8af1662b408282941e190da7f75b
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
- # YouPlot
1
+ ![Logo](https://user-images.githubusercontent.com/5798442/102004318-ec89d280-3d52-11eb-8608-d890b42593f1.png)
2
2
 
3
3
  ![Build Status](https://github.com/kojix2/youplot/workflows/test/badge.svg)
4
4
  [![Gem Version](https://badge.fury.io/rb/youplot.svg)](https://badge.fury.io/rb/youplot)
5
5
  [![Docs Latest](https://img.shields.io/badge/docs-latest-blue.svg)](https://rubydoc.info/gems/youplot)
6
6
  [![The MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
7
+ [![DOI](https://zenodo.org/badge/283230219.svg)](https://zenodo.org/badge/latestdoi/283230219)
7
8
 
8
- Create ASCII charts on the terminal with data from standard streams in the pipeline.
9
+ YouPlot is a command line tool for Unicode Plotting working with data from standard stream.
9
10
 
10
11
  :bar_chart: Powered by [UnicodePlot](https://github.com/red-data-tools/unicode_plot.rb)
11
12
 
@@ -15,16 +16,22 @@ Create ASCII charts on the terminal with data from standard streams in the pipel
15
16
  gem install youplot
16
17
  ```
17
18
 
18
- ## Screenshots
19
+ ## Quick Start
19
20
 
20
- **histogram**
21
+ `cat data.tsv | uplot <command> [options]`
22
+
23
+ ### barplot
21
24
 
22
25
  ```sh
23
- ruby -r numo/narray -e "puts Numo::DFloat.new(1000).rand_norm.to_a" \
24
- | uplot hist --nbins 15
26
+ curl -sL https://git.io/ISLANDScsv \
27
+ | sort -nk2 -t, \
28
+ | tail -n15 \
29
+ | uplot bar -d, -t "Areas of the World's Major Landmasses"
25
30
  ```
26
31
 
27
- <img src="https://i.imgur.com/wpsoGJq.png" width="75%" height="75%">
32
+ ![barplot](https://user-images.githubusercontent.com/5798442/101999903-d36a2d00-3d24-11eb-9361-b89116f44122.png)
33
+
34
+ ### histogram
28
35
 
29
36
  ```sh
30
37
  echo -e "from numpy import random;" \
@@ -33,91 +40,119 @@ echo -e "from numpy import random;" \
33
40
  | python \
34
41
  | uplot hist --nbins 20
35
42
  ```
43
+ ![histogram](https://user-images.githubusercontent.com/5798442/101999820-21cafc00-3d24-11eb-86db-e410d19b07df.png)
44
+
45
+ ### lineplot
36
46
 
37
- <img src="https://i.imgur.com/97R2MQx.png" width="75%" height="75%">
47
+ ```sh
48
+ curl -sL https://git.io/AirPassengers \
49
+ | cut -f2,3 -d, \
50
+ | uplot line -d, -w 50 -h 15 -t AirPassengers --xlim 1950,1960 --ylim 0,600
51
+ ```
38
52
 
39
- **scatter**
53
+ ![lineplot](https://user-images.githubusercontent.com/5798442/101999825-24c5ec80-3d24-11eb-99f4-c642e8d221bc.png)
54
+
55
+ ### scatter
40
56
 
41
57
  ```sh
42
- curl -s https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv \
43
- | cut -f1-4 -d, \
44
- | uplot scatter -H -d, -t IRIS
58
+ curl -sL https://git.io/IRIStsv \
59
+ | cut -f1-4 \
60
+ | uplot scatter -H -t IRIS
45
61
  ```
46
62
 
47
- <img src="https://i.imgur.com/STX7bFT.png" width="75%" height="75%">
63
+ ![scatter](https://user-images.githubusercontent.com/5798442/101999827-27284680-3d24-11eb-9903-551857eaa69c.png)
48
64
 
49
- **line**
65
+ ### density
50
66
 
51
67
  ```sh
52
- curl -s https://www.mhlw.go.jp/content/pcr_positive_daily.csv \
53
- | cut -f2 -d, \
54
- | uplot line -w 50 -h 15 -t 'PCR positive tests' --xlabel Date --ylabel number
68
+ curl -sL https://git.io/IRIStsv \
69
+ | cut -f1-4 \
70
+ | uplot density -H -t IRIS
55
71
  ```
56
72
 
57
- <img src="https://i.imgur.com/PVl5dsa.png" width="75%" height="75%">
73
+ ![density](https://user-images.githubusercontent.com/5798442/101999828-2abbcd80-3d24-11eb-902c-2f44266fa6ae.png)
58
74
 
59
- **box**
75
+ ### boxplot
60
76
 
61
77
  ```sh
62
- curl -s https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv \
63
- | cut -f1-4 -d, \
64
- | uplot box -H -d, -t IRIS
78
+ curl -sL https://git.io/IRIStsv \
79
+ | cut -f1-4 \
80
+ | uplot boxplot -H -t IRIS
65
81
  ```
66
82
 
67
- <img src="https://i.imgur.com/sNI4SmN.png" width="75%" height="75%">
83
+ ![boxplot](https://user-images.githubusercontent.com/5798442/101999830-2e4f5480-3d24-11eb-8891-728c18bf5b35.png)
84
+
85
+ ### count
68
86
 
69
- **colors**
87
+ In this example, YouPlot counts the number of chromosomes where the gene is located from the human gene annotation file and create a bar chart. The human gene annotation file can be downloaded from the following website.
88
+
89
+ * https://www.gencodegenes.org/human/
70
90
 
71
91
  ```sh
72
- uplot colors
92
+ cat gencode.v35.annotation.gff3 \
93
+ | grep -v '#' | grep 'gene' | cut -f1 | \
94
+ uplot count -t "The number of human gene annotations per chromosome" -c blue
73
95
  ```
74
96
 
75
- <img src="https://i.imgur.com/LxyHQsz.png">
97
+ ![count](https://user-images.githubusercontent.com/5798442/101999832-30b1ae80-3d24-11eb-96fe-e5000bed1f5c.png)
98
+
99
+ Note: `count` is not very fast because it runs in a Ruby script.
100
+ This is fine if the data is small, that is, in most cases. However, if you want to visualize huge data, it is faster to use a combination of common Unix commands as shown below.
101
+
102
+ ```sh
103
+ cat gencode.v35.annotation.gff3 | grep -v '#' | grep 'gene' | cut -f1 \
104
+ |sort | uniq -c | sort -nrk2 | awk '{print $2,$1}' \
105
+ | uplot bar -d ' ' -t "The number of human gene annotations per chromosome" -c blue
106
+ ```
76
107
 
77
108
  ## Usage
78
109
 
79
- `uplot --help`
110
+ ### Why YouPlot?
80
111
 
81
- ```
82
- Program: YouPlot (Tools for plotting on the terminal)
83
- Version: 0.2.7 (using UnicodePlot 0.0.4)
84
- Source: https://github.com/kojix2/youplot
112
+ Wouldn't it be a bit of pain to have to run R, Python, Julia, gnuplot or whatever REPL just to check your data?
113
+ YouPlot is a command line tool for this purpose. With YouPlot, you can continue working without leaving your terminal and shell.
85
114
 
86
- Usage: uplot <command> [options] <in.tsv>
115
+ ### how to use YouPlot?
87
116
 
88
- Commands:
89
- barplot bar
90
- histogram hist
91
- lineplot line
92
- lineplots lines
93
- scatter s
94
- density d
95
- boxplot box
96
- colors show the list of available colors
117
+ `uplot` is the shortened form of `youplot`. You can use either.
97
118
 
98
- count c baplot based on the number of occurrences
99
- (slower than `sort | uniq -c | sort -n -k1`)
119
+ | | |
120
+ |-----------------------------------|------------------------------------------------|
121
+ | Reads data from standard input | `cat data.tsv \| uplot <command> [options]` |
122
+ | Reads data from files | `uplot <command> [options] data.tsv ...` |
123
+ | Outputs data from stdin to stdout | `pipeline1 \| uplot <command> -O \| pipeline2` |
100
124
 
101
- Options:
102
- -O, --pass [VAL] file to output standard input data to [stdout]
103
- for inserting YouPlot in the middle of Unix pipes
104
- -o, --output VAL file to output results to [stderr]
105
- -d, --delimiter VAL use DELIM instead of TAB for field delimiter
106
- -H, --headers specify that the input has header row
107
- -T, --transpose transpose the axes of the input data
108
- -t, --title VAL print string on the top of plot
109
- -x, --xlabel VAL print string on the bottom of the plot
110
- -y, --ylabel VAL print string on the far left of the plot
111
- -w, --width VAL number of characters per row
112
- -h, --height VAL number of rows
113
- -b, --border VAL specify the style of the bounding box
114
- -m, --margin VAL number of spaces to the left of the plot
115
- -p, --padding VAL space of the left and right of the plot
116
- -c, --color VAL color of the drawing
117
- --[no-]labels hide the labels
118
- --fmt VAL xyxy : header is like x1, y1, x2, y2, x3, y3...
119
- xyy : header is like x, y1, y2, y2, y3...
120
- ```
125
+ ### Where to output the plot?
126
+
127
+ By default, the plot is output to *standard error output*.
128
+ The output file or stream for the plot can be specified with the `-o` option.
129
+
130
+ ### Where to output the input data?
131
+
132
+ By default, the input data is not output anywhere.
133
+ The `-O` option, with no arguments, outputs the input data directly to the standard output. This is useful when passing data to a subsequent pipeline.
134
+
135
+ ### What types of plots are available?
136
+
137
+ The following sub-commands are available
138
+
139
+ | command | short | how it works |
140
+ |-----------|-------|----------------------------------------|
141
+ | barplot | bar | draw a horizontal barplot |
142
+ | histogram | hist | draw a horizontal histogram |
143
+ | lineplot | line | draw a line chart |
144
+ | lineplots | lines | draw a line chart with multiple series |
145
+ | scatter | s | draw a scatter plot |
146
+ | density | d | draw a density plot |
147
+ | boxplot | box | draw a horizontal boxplot |
148
+
149
+ See Quick Start for `count`.
150
+
151
+ | command | short | how it works |
152
+ |-----------|-------|----------------------------------------------------------|
153
+ | count | c | draw a baplot based on the number of occurrences (slow) |
154
+
155
+ ### How to view detailed command line options
121
156
 
122
157
  Use `--help` to print command-specific options.
123
158
 
@@ -135,13 +170,29 @@ Options:
135
170
  ...
136
171
  ```
137
172
 
138
- ## Development
173
+ ### How to view the list of available colors?
139
174
 
140
- Let's keep it simple.
175
+ ```sh
176
+ uplot colors
177
+ ```
141
178
 
142
179
  ## Contributing
143
180
 
144
- Bug reports and pull requests are welcome on GitHub at [https://github.com/kojix2/youplot](https://github.com/kojix2/youplot).
181
+ * [Report bugs](https://github.com/kojix2/youplot/issues)
182
+ * Fix bugs and [submit pull requests](https://github.com/kojix2/youplot/pulls)
183
+ * Write, clarify, or fix documentation
184
+ * Suggest or add new features
185
+
186
+
187
+ ### Development
188
+
189
+ ```sh
190
+ git clone https://github.com/your_name/GR.rb # Clone the Git repo
191
+ cd GR.rb
192
+ bundle install # Install the gem dependencies
193
+ bundle exec rake test # Run the test
194
+ bundle exec rake install # Installation from source code
195
+ ```
145
196
 
146
197
  ## License
147
198
 
@@ -152,17 +152,23 @@ module YouPlot
152
152
  end
153
153
 
154
154
  def colors(color_names = false)
155
+ # FIXME
156
+ s = String.new
155
157
  UnicodePlot::StyledPrinter::TEXT_COLORS.each do |k, v|
156
- print v
157
- print k
158
+ s << v
159
+ s << k.to_s
158
160
  unless color_names
159
- print "\t"
160
- print ' ●'
161
+ s << "\t"
162
+ s << ' ●'
161
163
  end
162
- print "\033[0m"
163
- print "\t"
164
+ s << "\033[0m"
165
+ s << "\t"
164
166
  end
165
- puts
167
+ s << "\n"
168
+ def s.render(obj)
169
+ obj.print(self)
170
+ end
171
+ s
166
172
  end
167
173
 
168
174
  def check_series_size(data, fmt)
@@ -10,88 +10,100 @@ module YouPlot
10
10
  Data = Struct.new(:headers, :series)
11
11
 
12
12
  class Command
13
- attr_accessor :params
14
- attr_reader :data, :fmt, :parser
13
+ attr_accessor :command, :params, :options
14
+ attr_reader :data, :parser
15
15
 
16
16
  def initialize(argv = ARGV)
17
17
  @argv = argv
18
- @params = Params.new
19
18
  @parser = Parser.new
19
+ @command = nil
20
+ @params = nil
21
+ @options = nil
20
22
  @backend = YouPlot::Backends::UnicodePlotBackend
21
23
  end
22
24
 
23
25
  def run
24
26
  parser.parse_options(@argv)
25
- command = parser.command
26
- params = parser.params
27
- delimiter = parser.delimiter
28
- transpose = parser.transpose
29
- headers = parser.headers
30
- pass = parser.pass
31
- output = parser.output
32
- fmt = parser.fmt
33
- @encoding = parser.encoding
34
- @debug = parser.debug
35
-
36
- if command == :colors
37
- @backend.colors(parser.color_names)
38
- exit
39
- end
27
+ @command ||= parser.command
28
+ @options ||= parser.options
29
+ @params ||= parser.params
40
30
 
41
- # Sometimes the input file does not end with a newline code.
42
- while (input = Kernel.gets(nil))
43
-
44
- # Pass the input to subsequent pipelines
45
- case pass
46
- when IO
47
- pass.print(input)
48
- else
49
- if pass
50
- File.open(pass, 'w') do |f|
51
- f.print(input)
52
- end
53
- end
31
+ if %i[colors color colours colour].include? @command
32
+ plot = create_plot
33
+ output_plot(plot)
34
+ else
35
+ # Sometimes the input file does not end with a newline code.
36
+ while (input = Kernel.gets(nil))
37
+ main(input)
54
38
  end
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def main(input)
45
+ output_data(input)
46
+
47
+ @data = read_dsv(input)
48
+
49
+ pp @data if options[:debug]
50
+
51
+ plot = create_plot
52
+ output_plot(plot)
53
+ end
54
+
55
+ def read_dsv(input)
56
+ input = input.dup.force_encoding(options[:encoding]).encode('utf-8') if options[:encoding]
57
+ DSVReader.input(input, options[:delimiter], options[:headers], options[:transpose])
58
+ end
55
59
 
56
- @data = if @encoding
57
- input2 = input.dup.force_encoding(@encoding).encode('utf-8')
58
- DSVReader.input(input2, delimiter, headers, transpose)
59
- else
60
- DSVReader.input(input, delimiter, headers, transpose)
61
- end
62
-
63
- pp @data if @debug
64
-
65
- plot = case command
66
- when :bar, :barplot
67
- @backend.barplot(data, params, fmt)
68
- when :count, :c
69
- @backend.barplot(data, params, count: true)
70
- when :hist, :histogram
71
- @backend.histogram(data, params)
72
- when :line, :lineplot
73
- @backend.line(data, params, fmt)
74
- when :lines, :lineplots
75
- @backend.lines(data, params, fmt)
76
- when :scatter, :s
77
- @backend.scatter(data, params, fmt)
78
- when :density, :d
79
- @backend.density(data, params, fmt)
80
- when :box, :boxplot
81
- @backend.boxplot(data, params)
82
- else
83
- raise "unrecognized plot_type: #{command}"
84
- end
85
-
86
- case output
87
- when IO
88
- plot.render(output)
89
- else
90
- File.open(output, 'w') do |f|
91
- plot.render(f)
60
+ def create_plot
61
+ case command
62
+ when :bar, :barplot
63
+ @backend.barplot(data, params, options[:fmt])
64
+ when :count, :c
65
+ @backend.barplot(data, params, count: true)
66
+ when :hist, :histogram
67
+ @backend.histogram(data, params)
68
+ when :line, :lineplot
69
+ @backend.line(data, params, options[:fmt])
70
+ when :lines, :lineplots
71
+ @backend.lines(data, params, options[:fmt])
72
+ when :scatter, :s
73
+ @backend.scatter(data, params, options[:fmt])
74
+ when :density, :d
75
+ @backend.density(data, params, options[:fmt])
76
+ when :box, :boxplot
77
+ @backend.boxplot(data, params)
78
+ when :colors, :color, :colours, :colour
79
+ @backend.colors(options[:color_names])
80
+ else
81
+ raise "unrecognized plot_type: #{command}"
82
+ end
83
+ end
84
+
85
+ def output_data(input)
86
+ # Pass the input to subsequent pipelines
87
+ case options[:pass]
88
+ when IO
89
+ options[:pass].print(input)
90
+ else
91
+ if options[:pass]
92
+ File.open(options[:pass], 'w') do |f|
93
+ f.print(input)
92
94
  end
93
95
  end
96
+ end
97
+ end
94
98
 
99
+ def output_plot(plot)
100
+ case options[:output]
101
+ when IO
102
+ plot.render(options[:output])
103
+ else
104
+ File.open(options[:output], 'w') do |f|
105
+ plot.render(f)
106
+ end
95
107
  end
96
108
  end
97
109
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YouPlot
4
+ class Command
5
+ CmdOptions = Struct.new(
6
+ :delimiter,
7
+ :transpose,
8
+ :headers,
9
+ :pass,
10
+ :output,
11
+ :fmt,
12
+ :encoding,
13
+ :color_names,
14
+ :debug,
15
+ keyword_init: true
16
+ )
17
+ end
18
+ end
@@ -1,28 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'optparse'
4
- require_relative 'params'
4
+ require_relative 'cmd_options'
5
+ require_relative 'plot_params'
5
6
 
6
7
  module YouPlot
7
8
  class Command
8
9
  class Parser
9
- attr_reader :command, :params,
10
- :delimiter, :transpose, :headers, :pass, :output, :fmt,
11
- :color_names, :encoding, :debug
10
+ attr_reader :command, :options, :params
12
11
 
13
12
  def initialize
14
- @command = nil
15
- @params = Params.new
13
+ @command = nil
16
14
 
17
- @delimiter = "\t"
18
- @transpose = false
19
- @headers = nil
20
- @pass = false
21
- @output = $stderr
22
- @fmt = 'xyy'
23
- @encoding = nil
24
- @debug = false
25
- @color_names = false
15
+ @options = CmdOptions.new(
16
+ delimiter: "\t",
17
+ transpose: false,
18
+ headers: nil,
19
+ pass: false,
20
+ output: $stderr,
21
+ fmt: 'xyy',
22
+ encoding: nil,
23
+ color_names: false,
24
+ debug: false
25
+ )
26
+
27
+ @params = PlotParams.new
26
28
  end
27
29
 
28
30
  def create_default_parser
@@ -33,21 +35,22 @@ module YouPlot
33
35
  opt.on_tail('') # Add a blank line at the end
34
36
  opt.separator('')
35
37
  opt.on('Common options:')
36
- opt.on('-O', '--pass [VAL]', 'file to output standard input data to [stdout]',
38
+ opt.on('-O', '--pass [FILE]', 'file to output input data to [stdout]',
37
39
  'for inserting YouPlot in the middle of Unix pipes') do |v|
38
- @pass = v || $stdout
40
+ @options[:pass] = v || $stdout
39
41
  end
40
- opt.on('-o', '--output VAL', 'file to output results to [stderr]') do |v|
41
- @output = v
42
+ opt.on('-o', '--output [FILE]', 'file to output plots to [stdout]',
43
+ 'If no option is specified, plot will print to stderr') do |v|
44
+ @options[:output] = v || $stdout
42
45
  end
43
46
  opt.on('-d', '--delimiter VAL', String, 'use DELIM instead of TAB for field delimiter') do |v|
44
- @delimiter = v
47
+ @options[:delimiter] = v
45
48
  end
46
49
  opt.on('-H', '--headers', TrueClass, 'specify that the input has header row') do |v|
47
- @headers = v
50
+ @options[:headers] = v
48
51
  end
49
52
  opt.on('-T', '--transpose', TrueClass, 'transpose the axes of the input data') do |v|
50
- @transpose = v
53
+ @options[:transpose] = v
51
54
  end
52
55
  opt.on('-t', '--title VAL', String, 'print string on the top of plot') do |v|
53
56
  params.title = v
@@ -79,8 +82,11 @@ module YouPlot
79
82
  opt.on('--[no-]labels', TrueClass, 'hide the labels') do |v|
80
83
  params.labels = v
81
84
  end
85
+ opt.on('--progress', TrueClass, 'progressive') do |v|
86
+ @options[:progressive] = v
87
+ end
82
88
  opt.on('--encoding VAL', String, 'Specify the input encoding') do |v|
83
- @encoding = v
89
+ @options[:encoding] = v
84
90
  end
85
91
  # Optparse adds the help option, but it doesn't show up in usage.
86
92
  # This is why you need the code below.
@@ -89,7 +95,7 @@ module YouPlot
89
95
  exit
90
96
  end
91
97
  opt.on('--debug', TrueClass, 'print preprocessed data') do |v|
92
- @debug = v
98
+ @options[:debug] = v
93
99
  end
94
100
  yield opt if block_given?
95
101
  end
@@ -117,7 +123,7 @@ module YouPlot
117
123
  scatter s draw a scatter plot
118
124
  density d draw a density plot
119
125
  boxplot box draw a horizontal boxplot
120
- colors show the list of available colors
126
+ colors color show the list of available colors
121
127
 
122
128
  count c draw a baplot based on the number of
123
129
  occurrences (slow)
@@ -163,7 +169,7 @@ module YouPlot
163
169
  params.xscale = v
164
170
  end
165
171
  parser.on_head('--fmt VAL', String, 'xy : header is like x, y...', 'yx : header is like y, x...') do |v|
166
- @fmt = v
172
+ @options[:fmt] = v
167
173
  end
168
174
 
169
175
  when :count, :c
@@ -193,7 +199,7 @@ module YouPlot
193
199
  params.ylim = v.take(2)
194
200
  end
195
201
  parser.on_head('--fmt VAL', String, 'xy : header is like x, y...', 'yx : header is like y, x...') do |v|
196
- @fmt = v
202
+ @options[:fmt] = v
197
203
  end
198
204
 
199
205
  when :lineplots, :lines
@@ -206,8 +212,9 @@ module YouPlot
206
212
  parser.on_head('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
207
213
  params.ylim = v.take(2)
208
214
  end
209
- parser.on_head('--fmt VAL', String, 'xyxy : header is like x1, y1, x2, y2, x3, y3...', 'xyy : header is like x, y1, y2, y2, y3...') do |v|
210
- @fmt = v
215
+ parser.on_head('--fmt VAL', String, 'xyxy : header is like x1, y1, x2, y2, x3, y3...',
216
+ 'xyy : header is like x, y1, y2, y2, y3...') do |v|
217
+ @options[:fmt] = v
211
218
  end
212
219
 
213
220
  when :scatter, :s
@@ -220,8 +227,9 @@ module YouPlot
220
227
  parser.on_head('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
221
228
  params.ylim = v.take(2)
222
229
  end
223
- parser.on_head('--fmt VAL', String, 'xyxy : header is like x1, y1, x2, y2, x3, y3...', 'xyy : header is like x, y1, y2, y2, y3...') do |v|
224
- @fmt = v
230
+ parser.on_head('--fmt VAL', String, 'xyxy : header is like x1, y1, x2, y2, x3, y3...',
231
+ 'xyy : header is like x, y1, y2, y2, y3...') do |v|
232
+ @options[:fmt] = v
225
233
  end
226
234
 
227
235
  when :density, :d
@@ -234,8 +242,9 @@ module YouPlot
234
242
  parser.on_head('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
235
243
  params.ylim = v.take(2)
236
244
  end
237
- parser.on('--fmt VAL', String, 'xyxy : header is like x1, y1, x2, y2, x3, y3...', 'xyy : header is like x, y1, y2, y2, y3...') do |v|
238
- @fmt = v
245
+ parser.on('--fmt VAL', String, 'xyxy : header is like x1, y1, x2, y2, x3, y3...',
246
+ 'xyy : header is like x, y1, y2, y2, y3...') do |v|
247
+ @options[:fmt] = v
239
248
  end
240
249
 
241
250
  when :boxplot, :box
@@ -243,9 +252,9 @@ module YouPlot
243
252
  params.xlim = v.take(2)
244
253
  end
245
254
 
246
- when :colors
255
+ when :colors, :color, :colours, :colour
247
256
  parser.on_head('-n', '--names', 'show color names only', TrueClass) do |v|
248
- @color_names = v
257
+ @options[:color_names] = v
249
258
  end
250
259
 
251
260
  else
@@ -7,7 +7,7 @@ module YouPlot
7
7
  # * Here, I use Struct for 2 safety reason.
8
8
  # * The keys are static in Struct.
9
9
  # * Struct does not conflict with keyword arguments. Hash dose.
10
- Params = Struct.new(
10
+ PlotParams = Struct.new(
11
11
  # Sort me!
12
12
  :title,
13
13
  :width,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YouPlot
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youplot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-04 00:00:00.000000000 Z
11
+ date: 2020-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unicode_plot
@@ -112,8 +112,9 @@ files:
112
112
  - lib/youplot/backends/processing.rb
113
113
  - lib/youplot/backends/unicode_plot_backend.rb
114
114
  - lib/youplot/command.rb
115
- - lib/youplot/command/params.rb
115
+ - lib/youplot/command/cmd_options.rb
116
116
  - lib/youplot/command/parser.rb
117
+ - lib/youplot/command/plot_params.rb
117
118
  - lib/youplot/dsv_reader.rb
118
119
  - lib/youplot/version.rb
119
120
  homepage: https://github.com/kojix2/youplot