youplot 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/lib/youplot/backends/unicode_plot_backend.rb +16 -22
- data/lib/youplot/command.rb +11 -1
- data/lib/youplot/command/options.rb +1 -1
- data/lib/youplot/command/parser.rb +12 -4
- data/lib/youplot/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz: '
|
3
|
+
metadata.gz: 6bfd3292028fb88c3a5c902884d6c3dd17f59292eb4980b09a75396c921cb46f
|
4
|
+
data.tar.gz: '00524329ddcea39543d4a064e5f930c417544f86a853f538823eb6ece37ac255'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b37389aab9904bc7129397a8c04b6a1d6e244bc1af986f57d21131eec55cf7051308a7eabc2e81d17e8e4838d45d9c5d6cc65169375329e9884726a2ea49408
|
7
|
+
data.tar.gz: 6a1c8605980520e8d0bae43b0302d6e07d5511e6bf85d0fd3def1c6c994ed5e1375a076af69ef843b2a1a0f5e7bbbb877148ef03bf833a734c53c1115e59c0fd
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
<p align="center">
|
2
|
-
<img src="
|
3
|
-
</
|
2
|
+
<img src="logo.svg" width="60%" height="60%" />
|
3
|
+
</7>
|
4
4
|
|
5
5
|
![Build Status](https://github.com/kojix2/youplot/workflows/test/badge.svg)
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/youplot.svg)](https://badge.fury.io/rb/youplot)
|
7
|
-
[![Docs
|
7
|
+
[![Docs Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://rubydoc.info/gems/youplot)
|
8
8
|
[![The MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
|
9
9
|
[![DOI](https://zenodo.org/badge/283230219.svg)](https://zenodo.org/badge/latestdoi/283230219)
|
10
10
|
|
@@ -216,6 +216,8 @@ uplot colors
|
|
216
216
|
|
217
217
|
## Contributing
|
218
218
|
|
219
|
+
YouPlot is a library under development, so even small improvements like typofix are welcome! Please feel free to send us your pull requests.
|
220
|
+
|
219
221
|
* [Report bugs](https://github.com/kojix2/youplot/issues)
|
220
222
|
* Fix bugs and [submit pull requests](https://github.com/kojix2/youplot/pulls)
|
221
223
|
* Write, clarify, or fix documentation
|
@@ -226,8 +228,8 @@ uplot colors
|
|
226
228
|
### Development
|
227
229
|
|
228
230
|
```sh
|
229
|
-
|
230
|
-
|
231
|
+
# fork the main repository by clicking the Fork button.
|
232
|
+
git clone https://github.com/your_name/YouPlot
|
231
233
|
bundle install # Install the gem dependencies
|
232
234
|
bundle exec rake test # Run the test
|
233
235
|
bundle exec rake install # Installation from source code
|
@@ -39,19 +39,7 @@ module YouPlot
|
|
39
39
|
labels = series[x_col]
|
40
40
|
values = series[y_col].map(&:to_f)
|
41
41
|
end
|
42
|
-
|
43
|
-
UnicodePlot.barplot(labels, values, **params.to_hc)
|
44
|
-
# UnicodePlot error:
|
45
|
-
# All values have to be positive. Negative bars are not supported.
|
46
|
-
rescue ArgumentError => e
|
47
|
-
if YouPlot.run_as_executable?
|
48
|
-
warn e.backtrace[0]
|
49
|
-
warn "\e[35m#{e}\e[0m"
|
50
|
-
exit 1
|
51
|
-
else
|
52
|
-
raise e
|
53
|
-
end
|
54
|
-
end
|
42
|
+
UnicodePlot.barplot(labels, values, **params.to_hc)
|
55
43
|
end
|
56
44
|
|
57
45
|
def histogram(data, params)
|
@@ -190,18 +178,24 @@ module YouPlot
|
|
190
178
|
def check_series_size(data, fmt)
|
191
179
|
series = data.series
|
192
180
|
if series.size == 1
|
193
|
-
warn
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
181
|
+
warn <<~EOS
|
182
|
+
youplot: There is only one series of input data. Please check the delimiter.
|
183
|
+
|
184
|
+
Headers: \e[35m#{data.headers.inspect}\e[0m
|
185
|
+
The first item is: \e[35m\"#{series[0][0]}\"\e[0m
|
186
|
+
The last item is : \e[35m\"#{series[0][-1]}\"\e[0m
|
187
|
+
EOS
|
188
|
+
# NOTE: Error messages cannot be colored.
|
198
189
|
YouPlot.run_as_executable ? exit(1) : raise(Error)
|
199
190
|
end
|
200
191
|
if fmt == 'xyxy' && series.size.odd?
|
201
|
-
warn
|
202
|
-
|
203
|
-
|
204
|
-
|
192
|
+
warn <<~EOS
|
193
|
+
YouPlot: In the xyxy format, the number of series must be even.
|
194
|
+
|
195
|
+
Number of series: \e[35m#{series.size}\e[0m
|
196
|
+
Headers: \e[35m#{data.headers.inspect}\e[0m
|
197
|
+
EOS
|
198
|
+
# NOTE: Error messages cannot be colored.
|
205
199
|
YouPlot.run_as_executable ? exit(1) : raise(Error)
|
206
200
|
end
|
207
201
|
end
|
data/lib/youplot/command.rb
CHANGED
@@ -65,7 +65,17 @@ module YouPlot
|
|
65
65
|
|
66
66
|
pp @data if options[:debug]
|
67
67
|
|
68
|
-
|
68
|
+
if YouPlot.run_as_executable?
|
69
|
+
begin
|
70
|
+
plot = create_plot
|
71
|
+
rescue ArgumentError => e
|
72
|
+
warn e.backtrace[0]
|
73
|
+
warn "\e[35m#{e}\e[0m"
|
74
|
+
exit 1
|
75
|
+
end
|
76
|
+
else
|
77
|
+
plot = create_plot
|
78
|
+
end
|
69
79
|
output_plot(plot)
|
70
80
|
end
|
71
81
|
|
@@ -22,6 +22,7 @@ module YouPlot
|
|
22
22
|
pass: false,
|
23
23
|
output: $stderr,
|
24
24
|
fmt: 'xyy',
|
25
|
+
progressive: false,
|
25
26
|
encoding: nil,
|
26
27
|
color_names: false,
|
27
28
|
debug: false
|
@@ -70,7 +71,8 @@ module YouPlot
|
|
70
71
|
parser.on('-h', '--height INT', Numeric, 'number of rows') do |v|
|
71
72
|
params.height = v
|
72
73
|
end
|
73
|
-
|
74
|
+
border_options = UnicodePlot::BORDER_MAP.keys.join(', ')
|
75
|
+
parser.on('-b', '--border STR', String, 'specify the style of the bounding box', "(#{border_options})") do |v|
|
74
76
|
params.border = v.to_sym
|
75
77
|
end
|
76
78
|
parser.on('-m', '--margin INT', Numeric, 'number of spaces to the left of the plot') do |v|
|
@@ -88,6 +90,12 @@ module YouPlot
|
|
88
90
|
parser.on('-p', '--progress', TrueClass, 'progressive mode [experimental]') do |v|
|
89
91
|
options[:progressive] = v
|
90
92
|
end
|
93
|
+
parser.on('-C', '--color-output', TrueClass, 'colorize even if writing to a pipe') do |v|
|
94
|
+
UnicodePlot::StyledPrinter.define_method(:color?){ |o| true }
|
95
|
+
end
|
96
|
+
parser.on('-M', '--monochrome', TrueClass, 'no colouring even if writing to a tty') do |v|
|
97
|
+
UnicodePlot::StyledPrinter.define_method(:color?){ |o| false }
|
98
|
+
end
|
91
99
|
parser.on('--encoding STR', String, 'Specify the input encoding') do |v|
|
92
100
|
options[:encoding] = v
|
93
101
|
end
|
@@ -151,7 +159,7 @@ module YouPlot
|
|
151
159
|
def sub_parser_add_xscale
|
152
160
|
xscale_options = UnicodePlot::ValueTransformer::PREDEFINED_TRANSFORM_FUNCTIONS.keys.join(', ')
|
153
161
|
sub_parser.on_head('--xscale STR', String, "axis scaling (#{xscale_options})") do |v|
|
154
|
-
params.xscale = v
|
162
|
+
params.xscale = v.to_sym
|
155
163
|
end
|
156
164
|
end
|
157
165
|
|
@@ -163,13 +171,13 @@ module YouPlot
|
|
163
171
|
|
164
172
|
def sub_parser_add_xlim
|
165
173
|
sub_parser.on_head('--xlim FLOAT,FLOAT', Array, 'plotting range for the x coordinate') do |v|
|
166
|
-
params.xlim = v
|
174
|
+
params.xlim = v
|
167
175
|
end
|
168
176
|
end
|
169
177
|
|
170
178
|
def sub_parser_add_ylim
|
171
179
|
sub_parser.on_head('--ylim FLOAT,FLOAT', Array, 'plotting range for the y coordinate') do |v|
|
172
|
-
params.ylim = v
|
180
|
+
params.ylim = v
|
173
181
|
end
|
174
182
|
end
|
175
183
|
|
data/lib/youplot/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode_plot
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
|
-
rubygems_version: 3.2.
|
138
|
+
rubygems_version: 3.2.15
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: A command line tool for Unicode Plotting
|