Skip to content

Commit 119f557

Browse files
committed
Add example images in README.md
1 parent cb2324d commit 119f557

6 files changed

Lines changed: 54 additions & 7 deletions

File tree

README.md

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $ gem install unicode_plot
1010

1111
## Usage
1212

13-
```
13+
```ruby
1414
require 'unicode_plot'
1515

1616
x = 0.step(3*Math::PI, by: 3*Math::PI / 30)
@@ -28,12 +28,59 @@ You can get the results below by running the above script:
2828

2929
## Supported charts
3030

31-
- barplot
32-
- boxplot
33-
- densityplot
34-
- histogram
35-
- lineplot
36-
- scatterplot
31+
### barplot
32+
33+
```
34+
plot = UnicodePlot.barplot(data: {'foo': 20, 'bar': 50}, title: "Bar")
35+
plot.render($stdout)
36+
```
37+
38+
<img src="img/barplot.png" width="50%" />
39+
40+
### boxplot
41+
42+
```
43+
plot = UnicodePlot.boxplot(data: {foo: [1, 3, 5], bar: [3, 5, 7]}, title: "Box")
44+
plot.render($stdout)
45+
```
46+
47+
<img src="img/boxplot.png" width="50%" />
48+
49+
### densityplot
50+
51+
```ruby
52+
x = Array.new(500) { 20*rand - 10 } + Array.new(500) { 6*rand - 3 }
53+
y = Array.new(1000) { 30*rand - 10 }
54+
plot = UnicodePlot.densityplot(x, y, title: "Density")
55+
plot.render($stdout)
56+
```
57+
58+
<img src="img/densityplot.png" width="50%" />
59+
60+
### histogram
61+
62+
```ruby
63+
x = Array.new(100) { rand(10) } + Array.new(100) { rand(30) + 10 }
64+
plot = UnicodePlot.histogram(x, title: "Histogram")
65+
plot.render($stdout)
66+
```
67+
68+
<img src="img/histogram.png" width="50%" />
69+
70+
### lineplot
71+
72+
See Usage section above.
73+
74+
### scatterplot
75+
76+
```ruby
77+
x = Array.new(50) { rand(20) - 10 }
78+
y = x.map {|xx| xx*rand(30) - 10 }
79+
plot = UnicodePlot.scatterplot(x, y, title: "Scatter")
80+
plot.render($stdout)
81+
```
82+
83+
<img src="img/scatterplot.png" width="50%" />
3784

3885
## Acknowledgement
3986

img/barplot.png

17.4 KB
Loading

img/boxplot.png

19.2 KB
Loading

img/densityplot.png

85 KB
Loading

img/histogram.png

50.4 KB
Loading

img/scatterplot.png

38.1 KB
Loading

0 commit comments

Comments
 (0)