pax_global_header 0000666 0000000 0000000 00000000064 14026277515 0014523 g ustar 00root root 0000000 0000000 52 comment=caa4c5e055c44c2e48c317656ed0096f9a54b566
red-data-tools-unicode_plot.rb-b4b6a31/ 0000775 0000000 0000000 00000000000 14026277515 0020032 5 ustar 00root root 0000000 0000000 red-data-tools-unicode_plot.rb-b4b6a31/.github/ 0000775 0000000 0000000 00000000000 14026277515 0021372 5 ustar 00root root 0000000 0000000 red-data-tools-unicode_plot.rb-b4b6a31/.github/workflows/ 0000775 0000000 0000000 00000000000 14026277515 0023427 5 ustar 00root root 0000000 0000000 red-data-tools-unicode_plot.rb-b4b6a31/.github/workflows/ci.yml 0000664 0000000 0000000 00000002025 14026277515 0024544 0 ustar 00root root 0000000 0000000 name: CI
on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
test:
name: ${{ matrix.os }} ${{ matrix.ruby }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- ubuntu-18.04
- ubuntu-16.04
- macos-latest
- windows-latest
ruby:
- 3.0
- 2.7
- 2.6
- 2.5
- 2.4
- debug
include:
- { os: windows-latest , ruby: mingw }
- { os: windows-latest , ruby: mswin }
exclude:
- { os: windows-latest , ruby: 3.0 }
- { os: windows-latest , ruby: debug }
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- run: bundle install --jobs 4 --retry 3
- run: bundle exec rake
- run: bundle exec rake build
- run: gem install pkg/*.gem
red-data-tools-unicode_plot.rb-b4b6a31/.gitignore 0000664 0000000 0000000 00000000153 14026277515 0022021 0 ustar 00root root 0000000 0000000 Gemfile.lock
pkg/
tmp/
*~
# to prevent yard documentation from accidentally being checked in
.yardoc/
doc/ red-data-tools-unicode_plot.rb-b4b6a31/.yardopts 0000664 0000000 0000000 00000000123 14026277515 0021674 0 ustar 00root root 0000000 0000000 --output-dir doc/reference
--markup markdown
--no-private
lib/**/*.rb
-
doc/text/*
red-data-tools-unicode_plot.rb-b4b6a31/CHANGES.md 0000664 0000000 0000000 00000001762 14026277515 0021432 0 ustar 00root root 0000000 0000000 # 0.0.5
- Add stairs support
[GitHub#38][GitHub#17]
[Patch by @nanobowers]
- Add block canvas support
[GitHub#39][GitHub#19]
[Patch by @nanobowers]
- Add stemplot support
[GitHub#40][GitHub#30]
[Patch by @nanobowers]
- Add an example of animation
[GitHub#33]
[Patch by @mrkn and @kojix2]
- Fix interpolation bug of lineplot
[GitHub#37][GitHub#32]
[Patch by @nanobowers]
[Reported by @Nakilon]
- Support `color:` option in `render` method
[GitHub#45]
- Add `canvas_types` method
[GitHub#44][GitHub#42]
[Reported by @kojix2]
- Use appropriate message for invalid border types,
and add `border_types` method
[GitHub#43][GitHub#41]
[Reported by @kojix2]
# 0.0.4
- Fix error by requiring `stringio` [#22]
- Use enumerable-statistics >= 2.0.1 to avoid a bug of histogram [#28]
# 0.0.3
- Add histogram support
- Add barplot! method
- Add scatterplot support
- Add densityplot support
# 0.0.2
- Add boxplot support
# 0.0.1
- Add barplot support
- Add lineplot support
red-data-tools-unicode_plot.rb-b4b6a31/Gemfile 0000664 0000000 0000000 00000000251 14026277515 0021323 0 ustar 00root root 0000000 0000000 source "https://rubygems.org/"
gemspec
# Temporary use this for module_function decorator support
gem "yard", github: "mrkn/yard", branch: "module_function_decorator"
red-data-tools-unicode_plot.rb-b4b6a31/LICENSE.txt 0000664 0000000 0000000 00000002075 14026277515 0021661 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright © 2019 Kenta Murata
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
red-data-tools-unicode_plot.rb-b4b6a31/README.md 0000664 0000000 0000000 00000003473 14026277515 0021320 0 ustar 00root root 0000000 0000000 # UnicodePlot - Plot your data by Unicode characters
UnicodePlot provides the feature to make charts with Unicode characters.
## Documentation
https://red-data-tools.github.io/unicode_plot.rb/
## Install
```console
$ gem install unicode_plot
```
## Usage
```ruby
require 'unicode_plot'
x = 0.step(3*Math::PI, by: 3*Math::PI / 30)
y_sin = x.map {|xi| Math.sin(xi) }
y_cos = x.map {|xi| Math.cos(xi) }
plot = UnicodePlot.lineplot(x, y_sin, name: "sin(x)", width: 40, height: 10)
UnicodePlot.lineplot!(plot, x, y_cos, name: "cos(x)")
plot.render
```
You can get the results below by running the above script:
## Supported charts
### barplot
```ruby
UnicodePlot.barplot(data: {'foo': 20, 'bar': 50}, title: "Bar").render
```
### boxplot
```ruby
UnicodePlot.boxplot(data: {foo: [1, 3, 5], bar: [3, 5, 7]}, title: "Box").render
```
### densityplot
```ruby
x = Array.new(500) { 20*rand - 10 } + Array.new(500) { 6*rand - 3 }
y = Array.new(1000) { 30*rand - 10 }
UnicodePlot.densityplot(x, y, title: "Density").render
```
### histogram
```ruby
x = Array.new(100) { rand(10) } + Array.new(100) { rand(30) + 10 }
UnicodePlot.histogram(x, title: "Histogram").render
```
### lineplot
See [Usage](#usage) section above.
### scatterplot
```ruby
x = Array.new(50) { rand(20) - 10 }
y = x.map {|xx| xx*rand(30) - 10 }
UnicodePlot.scatterplot(x, y, title: "Scatter").render
```
## Acknowledgement
This library is strongly inspired by [UnicodePlot.jl](https://github.com/Evizero/UnicodePlots.jl).
## License
MIT License
## Author
- [Kenta Murata](https://github.com/mrkn)
red-data-tools-unicode_plot.rb-b4b6a31/Rakefile 0000664 0000000 0000000 00000000417 14026277515 0021501 0 ustar 00root root 0000000 0000000 require "bundler/gem_helper"
require "yard"
base_dir = File.expand_path("..", __FILE__)
helper = Bundler::GemHelper.new(base_dir)
helper.install
desc "Run test"
task :test do
ruby("test/run-test.rb")
end
task default: :test
YARD::Rake::YardocTask.new do |task|
end
red-data-tools-unicode_plot.rb-b4b6a31/example/ 0000775 0000000 0000000 00000000000 14026277515 0021465 5 ustar 00root root 0000000 0000000 red-data-tools-unicode_plot.rb-b4b6a31/example/animation.rb 0000664 0000000 0000000 00000001136 14026277515 0023772 0 ustar 00root root 0000000 0000000 require "unicode_plot"
require "stringio"
N = 1000
M = 50
out = StringIO.new
def out.tty?; true; end
shift = 0
continue = true
Signal.trap(:INT) { continue = false }
while continue
out.truncate(0)
xs = 0...N
ys = xs.map {|x| Math.sin(2*Math::PI*(x + shift) / N) }
UnicodePlot.lineplot(xs, ys, width: 60, height: 15).render(out)
lines = out.string.lines
lines.each do |line|
$stdout.print "\r#{line}"
end
$stdout.print "\e[0J"
$stdout.flush
sleep 0.2
if continue
n = lines.count
$stdout.print "\e[#{n}F"
shift = (shift + M) % N
end
end
$stdout.print "\e[0J"
red-data-tools-unicode_plot.rb-b4b6a31/example/ex_canvases.rb 0000775 0000000 0000000 00000000731 14026277515 0024315 0 ustar 00root root 0000000 0000000 #!/bin/env ruby
$LOAD_PATH << "#{__dir__}/../lib"
require "unicode_plot"
# example of line plots using different canvases
UnicodePlot.lineplot([1, 2, 7], [9, -6, 8], title: "Default Lineplot").render
UnicodePlot.lineplot([1, 2, 7], [9, -6, 8], title: "Ascii Lineplot", canvas: :ascii).render
UnicodePlot.lineplot([1, 2, 7], [9, -6, 8], title: "Dot Lineplot", canvas: :dot).render
UnicodePlot.lineplot([1, 2, 7], [9, -6, 8], title: "Block Lineplot", canvas: :block).render
red-data-tools-unicode_plot.rb-b4b6a31/example/ex_staircase_plot.rb 0000775 0000000 0000000 00000001244 14026277515 0025526 0 ustar 00root root 0000000 0000000 #!/bin/env ruby
$LOAD_PATH << "#{__dir__}/../lib"
require "unicode_plot"
# single plot at a time
UnicodePlot.stairs([1, 2, 4, 7, 8], [1, 3, 4, 2, 7], style: :post).render
# pre: style
UnicodePlot.stairs([1, 2, 4, 7, 8], [1, 3, 4, 2, 7], style: :pre).render
# Another single plot with title
UnicodePlot.stairs([2, 3, 5, 6, 9], [2, 5, 3, 4, 2], title: "My Staircase Plot").render
# Two plots at a time.
# Using an explicit limit because data for the 2nd plot is outside the bounds from the 1st plot
plot = UnicodePlot.stairs([1, 2, 4, 7, 8], [1, 3, 4, 2, 7], title: "Two Staircases", xlim: [1,10] )
UnicodePlot.stairs!(plot, [0, 3, 5, 6, 9], [2, 5, 3, 4, 0])
plot.render
red-data-tools-unicode_plot.rb-b4b6a31/example/ex_stemplot.rb 0000775 0000000 0000000 00000001704 14026277515 0024362 0 ustar 00root root 0000000 0000000 #!/bin/env ruby
# coding: utf-8
$LOAD_PATH << "#{__dir__}/../lib"
require "unicode_plot"
fifty_floats = 50.times.map { rand(-1000..1000)/350.0 }
eighty_ints = 80.times.map { rand(1..100) }
another_eighty_ints = 80.times.map { rand(1..100) }
three_hundred_ints = 300.times.map { rand(-100..100) }
UnicodePlot.stemplot(eighty_ints)
UnicodePlot.stemplot(three_hundred_ints)
UnicodePlot.stemplot(fifty_floats, scale: 1)
UnicodePlot.stemplot(fifty_floats, scale: 1, divider: "😄")
UnicodePlot.stemplot(eighty_ints, another_eighty_ints)
# Examples with strings
words_1 = %w[apple junk ant age bee bar baz dog egg a]
words_2 = %w[ape flan can cat juice elf gnome child fruit]
UnicodePlot.stemplot(words_1)
UnicodePlot.stemplot(words_1, words_2)
UnicodePlot.stemplot(words_1, scale: 100, trim: true)
UnicodePlot.stemplot(words_1, scale: 100, trim: true, string_padchar: '?')
floats = (-8..8).to_a.map { |a| a / 2.0 }
UnicodePlot.stemplot(floats, scale: 1)
red-data-tools-unicode_plot.rb-b4b6a31/example/issue32.rb 0000775 0000000 0000000 00000000367 14026277515 0023320 0 ustar 00root root 0000000 0000000 #!/bin/env ruby
$LOAD_PATH << "#{__dir__}/../lib"
require "unicode_plot"
ys = [261, 272, 277, 283, 289, 294, 298, 305, 309, 314, 319, 320, 322, 323, 324]
xs = ys.size.times.to_a
UnicodePlot.lineplot(xs, ys, height: 26, ylim: [0, 700]).render
red-data-tools-unicode_plot.rb-b4b6a31/img/ 0000775 0000000 0000000 00000000000 14026277515 0020606 5 ustar 00root root 0000000 0000000 red-data-tools-unicode_plot.rb-b4b6a31/img/barplot.png 0000664 0000000 0000000 00000042714 14026277515 0022767 0 ustar 00root root 0000000 0000000 PNG
IHDR 6 f|
iCCPICC Profile HPTW{mޖ{K/ҫ(,tX`"6$"" *
EbAD$(1X$1||g;{@a&'' $rҸ>Nv:n@ 4l厌~]-^?&ȎLe y!Ne%"܃=+ FX!3-ǪHoq:ޥE3?Y L&7 bg::u9Xb0H45xljDf_5x[0#)!Kwḡ.3-Ą? 9q) I q.wddD`"Xd
DvZdV #)y+76:&nb$֤݅ |\]?뮲$ FdTW7cs3s@]2@^c`lp-b@"w&A>(aPIN\ WupQLi,` D8$)A>d
YA;CP4āҡhT@P
@7a4 Aoea,
+:)l~f8NKR`AkC
HFF{z>s[LMMLMi^E70fvf;.}476O3?kEE
6LY[2-k,'VV'&嬙ֵll663jql_q{}CSGyh'#mN=g7..,&W}nd7_
g\nJ9;=!'^*^)^?yc+R}|}=WO
h
X
, t;X"86+RaMӡFcU6gmEbKaa̰sU'Qb^mإHȒș(˨hCs11e1؊qqqK
k m!Nddd
lUߺoLcXzsrvLn^wμӻv5&snnI={vM}MK>_>7|o~;`}
u
WXEQ;h}D$dǡRziAaoU!I?2Q^uT聣1vmURU9Z-]]X|"Zڲؓ'o}SD}aNDOc_ISSTsqܒ2w*i]Z5m"mg3/~asZT^ulX
>zۢ'.](|Rޥٗ{{D_
}t5>knn\w~߶
n<VmF?>hHxaÕGc<xRTi/jMO\xk審N=RM?/.ϬdV?}ZZ2"PQQ i uU|MYW(뾘1 Hᩛ 8qOD /Ri9kmmu \$% Ӣdad@ZgXDAш ];i`9 pHYs % %IR$ (iTXtXML:com.adobe.xmp
2
5
144
1
144
822
1
157
2019:06:20 11:06:46
Pixelmator 3.8.4
9 v> 7$IDATxp]y A(VQl%j.*eg";xlNqf'M63L2IٴIȖ[l˶Ubu%Jl @ w{@s}9zڎ @ @r )Jni9 @
' @ H45APx@ H4>n>JnB)P$DC H@ @ h:sNl"hTȇnY%kTA,4.B 0&PLsl<<"O5IK) ;{i 1-Mn>K;*k6j$@ @>|l2xp @ F nQVQ^*NfNK:Hy{!qmF5_;{VgxlcRTPueݯGLkd|qqq}@ k@ 2yVʢ93K'__υ)oB8p\Nr Ugɴ)URV-UAî/]4[c'eҨV#Һꥶzrv @ _ɗ ӎD )䅌`cYTӅv5O{AܶW+tl5KSw,U&7w