mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-09-20 11:48:07 +08:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
00c2ce9b44 | ||
![]() |
84196c197d | ||
![]() |
c40c59a21d | ||
![]() |
c4f21df588 | ||
![]() |
39166894a3 | ||
![]() |
7b8213833f | ||
![]() |
9090bbf51b | ||
![]() |
428d525c5f | ||
![]() |
6ebc707c51 |
47
README.md
47
README.md
@@ -9,8 +9,6 @@ Create ASCII charts on the terminal with data from standard streams in the pipel
|
|||||||
|
|
||||||
:bar_chart: Powered by [UnicodePlot](https://github.com/red-data-tools/unicode_plot.rb)
|
:bar_chart: Powered by [UnicodePlot](https://github.com/red-data-tools/unicode_plot.rb)
|
||||||
|
|
||||||
:construction: Under development! :construction:
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -26,22 +24,57 @@ ruby -r numo/narray -e "puts Numo::DFloat.new(1000).rand_norm.to_a" \
|
|||||||
| uplot hist --nbins 15
|
| uplot hist --nbins 15
|
||||||
```
|
```
|
||||||
|
|
||||||
<img src="https://i.imgur.com/wpsoGJq.png" width="75%" height="75%"></img>
|
<img src="https://i.imgur.com/wpsoGJq.png" width="75%" height="75%">
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo "from numpy import random;" \
|
||||||
|
"n = random.randn(10000);" \
|
||||||
|
"print('\n'.join(str(i) for i in n))" \
|
||||||
|
| python \
|
||||||
|
| uplot hist --nbins 20
|
||||||
|
```
|
||||||
|
|
||||||
|
<img src="https://i.imgur.com/97R2MQx.png" width="75%" height="75%">
|
||||||
|
|
||||||
**scatter**
|
**scatter**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
wget https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv -qO - \
|
curl -s https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv \
|
||||||
| cut -f1-4 -d, \
|
| cut -f1-4 -d, \
|
||||||
| uplot scatter -H -d, -t IRIS -m 10
|
| uplot scatter -H -d, -t IRIS
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<img src="https://i.imgur.com/STX7bFT.png" width="75%" height="75%">
|
||||||
|
|
||||||
|
**line**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -s https://www.mhlw.go.jp/content/pcr_positive_daily.csv \
|
||||||
|
| cut -f2 -d, \
|
||||||
|
| uplot line -w 50 -h 15 -t 'PCR positive tests' --xlabel Date --ylabel number
|
||||||
|
```
|
||||||
|
|
||||||
|
<img src="https://i.imgur.com/PVl5dsa.png" width="75%" height="75%">
|
||||||
|
|
||||||
|
**box**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -s https://raw.githubusercontent.com/uiuc-cse/data-fa14/gh-pages/data/iris.csv \
|
||||||
|
| cut -f1-4 -d, \
|
||||||
|
| uplot box -H -d, -t IRIS
|
||||||
|
```
|
||||||
|
|
||||||
|
<img src="https://i.imgur.com/sNI4SmN.png" width="75%" height="75%">
|
||||||
|
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
|
Let's keep it simple.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Bug reports and pull requests are welcome on GitHub at [https://github.com/kojix2/uplot](https://github.com/kojix2/uplot).
|
Bug reports and pull requests are welcome on GitHub at [https://github.com/kojix2/uplot](https://github.com/kojix2/uplot).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
[MIT License](https://opensource.org/licenses/MIT).
|
||||||
|
@@ -10,22 +10,26 @@ module Uplot
|
|||||||
:delimiter, :transpose, :headers, :pass, :output, :fmt, :debug
|
:delimiter, :transpose, :headers, :pass, :output, :fmt, :debug
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@command = nil
|
@command = nil
|
||||||
@params = Params.new
|
@params = Params.new
|
||||||
|
|
||||||
@delimiter = "\t"
|
@delimiter = "\t"
|
||||||
@transpose = false
|
@transpose = false
|
||||||
@headers = nil
|
@headers = nil
|
||||||
@pass = false
|
@pass = false
|
||||||
@output = $stderr
|
@output = $stderr
|
||||||
@fmt = 'xyy'
|
@fmt = 'xyy'
|
||||||
@debug = false
|
@debug = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_default_parser
|
def create_default_parser
|
||||||
OptionParser.new do |opt|
|
OptionParser.new do |opt|
|
||||||
opt.program_name = 'uplot'
|
opt.program_name = 'uplot'
|
||||||
opt.version = Uplot::VERSION
|
opt.version = Uplot::VERSION
|
||||||
|
opt.summary_width = 24
|
||||||
|
opt.on_tail('') # Add a blank line at the end
|
||||||
|
opt.separator('')
|
||||||
|
opt.on('Options:')
|
||||||
opt.on('-O', '--pass [VAL]', 'file to output standard input data to [stdout]',
|
opt.on('-O', '--pass [VAL]', 'file to output standard input data to [stdout]',
|
||||||
'for inserting uplot in the middle of Unix pipes') do |v|
|
'for inserting uplot in the middle of Unix pipes') do |v|
|
||||||
@pass = v || $stdout
|
@pass = v || $stdout
|
||||||
@@ -87,22 +91,22 @@ module Uplot
|
|||||||
# Usage and help messages
|
# Usage and help messages
|
||||||
main_parser.banner = \
|
main_parser.banner = \
|
||||||
<<~MSG
|
<<~MSG
|
||||||
|
|
||||||
Program: uplot (Tools for plotting on the terminal)
|
Program: uplot (Tools for plotting on the terminal)
|
||||||
Version: #{Uplot::VERSION} (using UnicodePlot #{UnicodePlot::VERSION})
|
Version: #{Uplot::VERSION} (using UnicodePlot #{UnicodePlot::VERSION})
|
||||||
Author: kojix2 <2xijok@gmail.com>
|
|
||||||
Source: https://github.com/kojix2/uplot
|
Source: https://github.com/kojix2/uplot
|
||||||
|
|
||||||
Usage: uplot <command> [options]
|
Usage: uplot <command> [options]
|
||||||
|
|
||||||
Command: barplot bar
|
Commands:
|
||||||
histogram hist
|
barplot bar
|
||||||
lineplot line
|
histogram hist
|
||||||
scatter s
|
lineplot line
|
||||||
density d
|
lineplots lines
|
||||||
boxplot box
|
scatter s
|
||||||
colors
|
density d
|
||||||
|
boxplot box
|
||||||
Options:
|
colors
|
||||||
MSG
|
MSG
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -110,9 +114,10 @@ module Uplot
|
|||||||
def sub_parser
|
def sub_parser
|
||||||
@sub_parser ||= create_default_parser do |parser|
|
@sub_parser ||= create_default_parser do |parser|
|
||||||
parser.banner = <<~MSG
|
parser.banner = <<~MSG
|
||||||
|
|
||||||
Usage: uplot #{command} [options]
|
Usage: uplot #{command} [options]
|
||||||
|
|
||||||
Options:
|
Options for #{command}:
|
||||||
MSG
|
MSG
|
||||||
|
|
||||||
case command
|
case command
|
||||||
@@ -121,80 +126,80 @@ module Uplot
|
|||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
when :barplot, :bar
|
when :barplot, :bar
|
||||||
parser.on('--symbol VAL', String, 'character to be used to plot the bars') do |v|
|
parser.on_head('--symbol VAL', String, 'character to be used to plot the bars') do |v|
|
||||||
params.symbol = v
|
params.symbol = v
|
||||||
end
|
end
|
||||||
parser.on('--xscale VAL', String, 'axis scaling') do |v|
|
parser.on_head('--xscale VAL', String, 'axis scaling') do |v|
|
||||||
params.xscale = v
|
params.xscale = v
|
||||||
end
|
end
|
||||||
|
|
||||||
when :count, :c
|
when :count, :c
|
||||||
parser.on('--symbol VAL', String, 'character to be used to plot the bars') do |v|
|
parser.on_head('--symbol VAL', String, 'character to be used to plot the bars') do |v|
|
||||||
params.symbol = v
|
params.symbol = v
|
||||||
end
|
end
|
||||||
|
|
||||||
when :histogram, :hist
|
when :histogram, :hist
|
||||||
parser.on('-n', '--nbins VAL', Numeric, 'approximate number of bins') do |v|
|
parser.on_head('-n', '--nbins VAL', Numeric, 'approximate number of bins') do |v|
|
||||||
params.nbins = v
|
params.nbins = v
|
||||||
end
|
end
|
||||||
parser.on('--closed VAL', String) do |v|
|
parser.on_head('--closed VAL', String) do |v|
|
||||||
params.closed = v
|
params.closed = v
|
||||||
end
|
end
|
||||||
parser.on('--symbol VAL', String, 'character to be used to plot the bars') do |v|
|
parser.on_head('--symbol VAL', String, 'character to be used to plot the bars') do |v|
|
||||||
params.symbol = v
|
params.symbol = v
|
||||||
end
|
end
|
||||||
|
|
||||||
when :lineplot, :line
|
when :lineplot, :line
|
||||||
parser.on('--canvas VAL', String, 'type of canvas') do |v|
|
parser.on_head('--canvas VAL', String, 'type of canvas') do |v|
|
||||||
params.canvas = v
|
params.canvas = v
|
||||||
end
|
end
|
||||||
parser.on('--xlim VAL', Array, 'plotting range for the x coordinate') do |v|
|
parser.on_head('--xlim VAL', Array, 'plotting range for the x coordinate') do |v|
|
||||||
params.xlim = v.take(2)
|
params.xlim = v.take(2)
|
||||||
end
|
end
|
||||||
parser.on('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
|
parser.on_head('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
|
||||||
params.ylim = v.take(2)
|
params.ylim = v.take(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
when :lineplots, :lines
|
when :lineplots, :lines
|
||||||
parser.on('--canvas VAL', String) do |v|
|
parser.on_head('--canvas VAL', String) do |v|
|
||||||
params.canvas = v
|
params.canvas = v
|
||||||
end
|
end
|
||||||
parser.on('--xlim VAL', Array, 'plotting range for the x coordinate') do |v|
|
parser.on_head('--xlim VAL', Array, 'plotting range for the x coordinate') do |v|
|
||||||
params.xlim = v.take(2)
|
params.xlim = v.take(2)
|
||||||
end
|
end
|
||||||
parser.on('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
|
parser.on_head('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
|
||||||
params.ylim = v.take(2)
|
params.ylim = v.take(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
when :scatter, :s
|
when :scatter, :s
|
||||||
parser.on('--canvas VAL', String) do |v|
|
parser.on_head('--canvas VAL', String) do |v|
|
||||||
params.canvas = v
|
params.canvas = v
|
||||||
end
|
end
|
||||||
parser.on('--xlim VAL', Array, 'plotting range for the x coordinate') do |v|
|
parser.on_head('--xlim VAL', Array, 'plotting range for the x coordinate') do |v|
|
||||||
params.xlim = v.take(2)
|
params.xlim = v.take(2)
|
||||||
end
|
end
|
||||||
parser.on('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
|
parser.on_head('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
|
||||||
params.ylim = v.take(2)
|
params.ylim = v.take(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
when :density, :d
|
when :density, :d
|
||||||
parser.on('--grid', TrueClass) do |v|
|
parser.on_head('--grid', TrueClass) do |v|
|
||||||
params.grid = v
|
params.grid = v
|
||||||
end
|
end
|
||||||
parser.on('--xlim VAL', Array, 'plotting range for the x coordinate') do |v|
|
parser.on_head('--xlim VAL', Array, 'plotting range for the x coordinate') do |v|
|
||||||
params.xlim = v.take(2)
|
params.xlim = v.take(2)
|
||||||
end
|
end
|
||||||
parser.on('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
|
parser.on_head('--ylim VAL', Array, 'plotting range for the y coordinate') do |v|
|
||||||
params.ylim = v.take(2)
|
params.ylim = v.take(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
when :boxplot, :box
|
when :boxplot, :box
|
||||||
parser.on('--xlim VAL', Array, 'plotting range for the x coordinate') do |v|
|
parser.on_head('--xlim VAL', Array, 'plotting range for the x coordinate') do |v|
|
||||||
params.xlim = v.take(2)
|
params.xlim = v.take(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
when :colors
|
when :colors
|
||||||
parser.on('-n', '--names', TrueClass) do |v|
|
parser.on_head('-n', '--names', TrueClass) do |v|
|
||||||
@color_names = v
|
@color_names = v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Uplot
|
module Uplot
|
||||||
VERSION = '0.2.6'
|
VERSION = '0.2.7'
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user