Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/red-data-tools/unicode_plot.rb
Plot your data by Unicode characters
https://github.com/red-data-tools/unicode_plot.rb
data-science data-visualization ruby
Last synced: 3 months ago
JSON representation
Plot your data by Unicode characters
- Host: GitHub
- URL: https://github.com/red-data-tools/unicode_plot.rb
- Owner: red-data-tools
- License: mit
- Created: 2019-06-06T00:22:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-22T03:10:55.000Z (over 1 year ago)
- Last Synced: 2024-07-19T04:57:49.347Z (4 months ago)
- Topics: data-science, data-visualization, ruby
- Language: Ruby
- Size: 716 KB
- Stars: 245
- Watchers: 9
- Forks: 12
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# 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)