Skip to content

Commit b5da220

Browse files
committed
adding stemplot to readme per red-data-tools#56
1 parent caa4c5e commit b5da220

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,53 @@ UnicodePlot.scatterplot(x, y, title: "Scatter").render
8080

8181
<img src="img/scatterplot.png" width="50%" />
8282

83+
### stemplot
84+
85+
#### Two-sided stemplot of numbers
86+
```ruby
87+
eighty_ints = 80.times.map { rand(1..100) }
88+
another_eighty_ints = 80.times.map { rand(1..100) }
89+
# two-sided stem plot
90+
UnicodePlot.stemplot(eighty_ints, another_eighty_ints)
91+
```
92+
93+
output:
94+
```
95+
88544 | 0 | 22345569
96+
999955431 | 1 | 0445566688
97+
98110 | 2 | 0568
98+
85433221100 | 3 | 0234568
99+
553220 | 4 | 23367
100+
9777662 | 5 | 22334446679
101+
988855321 | 6 | 012245555889
102+
9985510 | 7 | 00044556789
103+
766555444100 | 8 | 0134678
104+
87776332 | 9 | 13347
105+
0 | 10 |
106+
Key: 1|0 = 10
107+
The decimal is 1 digit(s) to the right of |
108+
```
109+
110+
#### One-sided stem-plot of strings
111+
```ruby
112+
UnicodePlot.stemplot(eighty_ints)
113+
words_1 = %w[apple junk ant age bee bar baz dog egg a]
114+
UnicodePlot.stemplot(words_1)
115+
```
116+
117+
output:
118+
```
119+
a | _gnp
120+
b | aae
121+
c |
122+
d | o
123+
e | g
124+
f |
125+
g |
126+
h |
127+
i |
128+
j | u
129+
```
83130
## Acknowledgement
84131

85132
This library is strongly inspired by [UnicodePlot.jl](https://github.com/Evizero/UnicodePlots.jl).

0 commit comments

Comments
 (0)