charty 0.2.0 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +71 -0
- data/.github/workflows/nmatrix.yml +67 -0
- data/.github/workflows/pycall.yml +86 -0
- data/Dockerfile.dev +9 -1
- data/Gemfile +18 -0
- data/README.md +177 -9
- data/Rakefile +4 -5
- data/charty.gemspec +10 -4
- data/examples/Gemfile +1 -0
- data/examples/active_record.ipynb +1 -1
- data/examples/daru.ipynb +1 -1
- data/examples/iris_dataset.ipynb +1 -1
- data/examples/nmatrix.ipynb +1 -1
- data/examples/{numo-narray.ipynb → numo_narray.ipynb} +1 -1
- data/examples/palette.rb +71 -0
- data/examples/sample.png +0 -0
- data/examples/sample_images/hist_gruff.png +0 -0
- data/examples/sample_pyplot.ipynb +40 -38
- data/images/penguins_body_mass_g_flipper_length_mm_scatter_plot.png +0 -0
- data/images/penguins_body_mass_g_flipper_length_mm_species_scatter_plot.png +0 -0
- data/images/penguins_body_mass_g_flipper_length_mm_species_sex_scatter_plot.png +0 -0
- data/images/penguins_species_body_mass_g_bar_plot_h.png +0 -0
- data/images/penguins_species_body_mass_g_bar_plot_v.png +0 -0
- data/images/penguins_species_body_mass_g_box_plot_h.png +0 -0
- data/images/penguins_species_body_mass_g_box_plot_v.png +0 -0
- data/images/penguins_species_body_mass_g_sex_bar_plot_v.png +0 -0
- data/images/penguins_species_body_mass_g_sex_box_plot_v.png +0 -0
- data/lib/charty.rb +13 -1
- data/lib/charty/backend_methods.rb +8 -0
- data/lib/charty/backends.rb +26 -1
- data/lib/charty/backends/bokeh.rb +31 -31
- data/lib/charty/backends/{google_chart.rb → google_charts.rb} +75 -33
- data/lib/charty/backends/gruff.rb +14 -3
- data/lib/charty/backends/plotly.rb +774 -9
- data/lib/charty/backends/pyplot.rb +611 -34
- data/lib/charty/backends/rubyplot.rb +2 -2
- data/lib/charty/backends/unicode_plot.rb +79 -0
- data/lib/charty/dash_pattern_generator.rb +57 -0
- data/lib/charty/index.rb +213 -0
- data/lib/charty/linspace.rb +1 -1
- data/lib/charty/plot_methods.rb +254 -0
- data/lib/charty/plotter.rb +10 -10
- data/lib/charty/plotters.rb +12 -0
- data/lib/charty/plotters/abstract_plotter.rb +243 -0
- data/lib/charty/plotters/bar_plotter.rb +201 -0
- data/lib/charty/plotters/box_plotter.rb +79 -0
- data/lib/charty/plotters/categorical_plotter.rb +380 -0
- data/lib/charty/plotters/count_plotter.rb +7 -0
- data/lib/charty/plotters/estimation_support.rb +84 -0
- data/lib/charty/plotters/line_plotter.rb +300 -0
- data/lib/charty/plotters/random_support.rb +25 -0
- data/lib/charty/plotters/relational_plotter.rb +635 -0
- data/lib/charty/plotters/scatter_plotter.rb +80 -0
- data/lib/charty/plotters/vector_plotter.rb +6 -0
- data/lib/charty/statistics.rb +114 -0
- data/lib/charty/table.rb +161 -15
- data/lib/charty/table_adapters.rb +2 -0
- data/lib/charty/table_adapters/active_record_adapter.rb +17 -9
- data/lib/charty/table_adapters/base_adapter.rb +166 -0
- data/lib/charty/table_adapters/daru_adapter.rb +41 -3
- data/lib/charty/table_adapters/datasets_adapter.rb +17 -2
- data/lib/charty/table_adapters/hash_adapter.rb +143 -16
- data/lib/charty/table_adapters/narray_adapter.rb +25 -6
- data/lib/charty/table_adapters/nmatrix_adapter.rb +15 -5
- data/lib/charty/table_adapters/pandas_adapter.rb +163 -0
- data/lib/charty/util.rb +28 -0
- data/lib/charty/vector.rb +69 -0
- data/lib/charty/vector_adapters.rb +187 -0
- data/lib/charty/vector_adapters/array_adapter.rb +101 -0
- data/lib/charty/vector_adapters/daru_adapter.rb +163 -0
- data/lib/charty/vector_adapters/narray_adapter.rb +182 -0
- data/lib/charty/vector_adapters/nmatrix_adapter.rb +37 -0
- data/lib/charty/vector_adapters/numpy_adapter.rb +168 -0
- data/lib/charty/vector_adapters/pandas_adapter.rb +199 -0
- data/lib/charty/version.rb +1 -1
- metadata +121 -22
- data/.travis.yml +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63e13663e8213e077993e52b906b630c35a1f7f9a224abb99fd206bb700659c2
|
4
|
+
data.tar.gz: d7fd53056c32c18bf5af6b1e1a4b2a29bfe652a427b338087d3cab538a0797ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc4da146432f688eb52dd382ea516e02ab84ef7143453c80fa5bc14fef55851728550ee58fe98c1c3a5e9a1eac0f33dcfb702356bc7c0f344ceaf85f87400435
|
7
|
+
data.tar.gz: f519610073317c3fafd42b97ad5e96d124265f6a7d79a54023995cf82d1fe84624d4f914c26e3eef644ad280110400fe1cdac275ec5e32145d7e4b652ef47891
|
@@ -0,0 +1,71 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
types:
|
9
|
+
- opened
|
10
|
+
- synchronize
|
11
|
+
- reopened
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
test:
|
15
|
+
name: ${{ matrix.os }}/${{ matrix.ruby }}
|
16
|
+
runs-on: ${{ matrix.os }}
|
17
|
+
strategy:
|
18
|
+
fail-fast: false
|
19
|
+
matrix:
|
20
|
+
os:
|
21
|
+
- ubuntu-20.04
|
22
|
+
- ubuntu-18.04
|
23
|
+
ruby:
|
24
|
+
- "3.0"
|
25
|
+
- 2.7
|
26
|
+
- 2.6
|
27
|
+
include:
|
28
|
+
- { os: ubuntu-20.04 , ruby: head }
|
29
|
+
|
30
|
+
steps:
|
31
|
+
- uses: actions/checkout@v2
|
32
|
+
|
33
|
+
- name: Set up Ruby
|
34
|
+
uses: ruby/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: ${{ matrix.ruby }}
|
37
|
+
|
38
|
+
- uses: actions/cache@v2
|
39
|
+
if: runner.os == 'Linux'
|
40
|
+
with:
|
41
|
+
path: ~/.cache/red-datasets
|
42
|
+
key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
|
43
|
+
restore-keys: ${{ runner.os }}-
|
44
|
+
|
45
|
+
- uses: actions/cache@v2
|
46
|
+
if: |
|
47
|
+
runner.os == 'macOS'
|
48
|
+
with:
|
49
|
+
path: |
|
50
|
+
~/Library/Caches/red-datasets
|
51
|
+
key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
|
52
|
+
restore-keys: ${{ runner.os }}-
|
53
|
+
|
54
|
+
- uses: actions/cache@v2
|
55
|
+
if: |
|
56
|
+
runner.os == 'Windows'
|
57
|
+
with:
|
58
|
+
path: |
|
59
|
+
~/AppData/red-datasets
|
60
|
+
key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
|
61
|
+
restore-keys: ${{ runner.os }}-
|
62
|
+
|
63
|
+
- run: sudo apt install build-essential libsqlite3-dev
|
64
|
+
|
65
|
+
- run: bundle install --jobs 4 --retry 3 --without "nmatrix python"
|
66
|
+
|
67
|
+
- run: bundle exec rake
|
68
|
+
|
69
|
+
- run: rake build
|
70
|
+
|
71
|
+
- run: gem install --user pkg/*.gem
|
@@ -0,0 +1,67 @@
|
|
1
|
+
name: CI with NMatrix
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
types:
|
9
|
+
- opened
|
10
|
+
- synchronize
|
11
|
+
- reopened
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
test:
|
15
|
+
name: ${{ matrix.os }}/${{ matrix.ruby }}
|
16
|
+
runs-on: ${{ matrix.os }}
|
17
|
+
strategy:
|
18
|
+
fail-fast: false
|
19
|
+
matrix:
|
20
|
+
os:
|
21
|
+
- ubuntu-20.04
|
22
|
+
ruby:
|
23
|
+
- 2.7
|
24
|
+
- 2.6
|
25
|
+
|
26
|
+
steps:
|
27
|
+
- uses: actions/checkout@v2
|
28
|
+
|
29
|
+
- name: Set up Ruby
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
33
|
+
|
34
|
+
- uses: actions/cache@v2
|
35
|
+
if: runner.os == 'Linux'
|
36
|
+
with:
|
37
|
+
path: ~/.cache/red-datasets
|
38
|
+
key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
|
39
|
+
restore-keys: ${{ runner.os }}-
|
40
|
+
|
41
|
+
- uses: actions/cache@v2
|
42
|
+
if: |
|
43
|
+
runner.os == 'macOS'
|
44
|
+
with:
|
45
|
+
path: |
|
46
|
+
~/Library/Caches/red-datasets
|
47
|
+
key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
|
48
|
+
restore-keys: ${{ runner.os }}-
|
49
|
+
|
50
|
+
- uses: actions/cache@v2
|
51
|
+
if: |
|
52
|
+
runner.os == 'Windows'
|
53
|
+
with:
|
54
|
+
path: |
|
55
|
+
~/AppData/red-datasets
|
56
|
+
key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
|
57
|
+
restore-keys: ${{ runner.os }}-
|
58
|
+
|
59
|
+
- run: sudo apt install build-essential libsqlite3-dev
|
60
|
+
|
61
|
+
- run: bundle install --jobs 4 --retry 3 --without "numo python"
|
62
|
+
|
63
|
+
- run: bundle exec rake
|
64
|
+
|
65
|
+
- run: rake build
|
66
|
+
|
67
|
+
- run: gem install --user pkg/*.gem
|
@@ -0,0 +1,86 @@
|
|
1
|
+
name: CI with matplotlib and pandas
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
types:
|
9
|
+
- opened
|
10
|
+
- synchronize
|
11
|
+
- reopened
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
test:
|
15
|
+
name: ${{ matrix.os }}/${{ matrix.ruby }}/${{ matrix.python }}-${{ matrix.python_architecture }}
|
16
|
+
runs-on: ${{ matrix.os }}
|
17
|
+
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
os:
|
22
|
+
- ubuntu-20.04
|
23
|
+
- ubuntu-18.04
|
24
|
+
ruby:
|
25
|
+
- "3.0"
|
26
|
+
- 2.7
|
27
|
+
- 2.6
|
28
|
+
python:
|
29
|
+
- 3.x
|
30
|
+
- 2.x
|
31
|
+
python_architecture:
|
32
|
+
- x64
|
33
|
+
include:
|
34
|
+
- { os: ubuntu-20.04 , ruby: head , python: 3.x , python_architecture: x64 }
|
35
|
+
|
36
|
+
steps:
|
37
|
+
- uses: actions/checkout@v2
|
38
|
+
|
39
|
+
- name: Setup Ruby
|
40
|
+
uses: ruby/setup-ruby@v1
|
41
|
+
with:
|
42
|
+
ruby-version: ${{ matrix.ruby }}
|
43
|
+
|
44
|
+
- name: Setup Python
|
45
|
+
uses: actions/setup-python@v2
|
46
|
+
with:
|
47
|
+
python-version: ${{ matrix.python }}
|
48
|
+
architecture: ${{ matrix.python_architecture }}
|
49
|
+
|
50
|
+
- uses: actions/cache@v2
|
51
|
+
if: runner.os == 'Linux'
|
52
|
+
with:
|
53
|
+
path: ~/.cache/red-datasets
|
54
|
+
key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
|
55
|
+
restore-keys: ${{ runner.os }}-
|
56
|
+
|
57
|
+
- uses: actions/cache@v2
|
58
|
+
if: |
|
59
|
+
runner.os == 'macOS'
|
60
|
+
with:
|
61
|
+
path: |
|
62
|
+
~/Library/Caches/red-datasets
|
63
|
+
key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
|
64
|
+
restore-keys: ${{ runner.os }}-
|
65
|
+
|
66
|
+
- uses: actions/cache@v2
|
67
|
+
if: |
|
68
|
+
runner.os == 'Windows'
|
69
|
+
with:
|
70
|
+
path: |
|
71
|
+
~/AppData/red-datasets
|
72
|
+
key: ${{ runner.os }}-${{ hashFiles('lib/**') }}
|
73
|
+
restore-keys: ${{ runner.os }}-
|
74
|
+
|
75
|
+
- run: sudo apt install build-essential libsqlite3-dev
|
76
|
+
|
77
|
+
- run: pip install --user matplotlib pandas
|
78
|
+
|
79
|
+
- run: bundle install --jobs 4 --retry 3 --without "nmatrix numo"
|
80
|
+
|
81
|
+
- run: python -V
|
82
|
+
|
83
|
+
- run: bundle exec rake
|
84
|
+
env:
|
85
|
+
PYTHON: python
|
86
|
+
continue-on-error: ${{ matrix.python == '2.x' }}
|
data/Dockerfile.dev
CHANGED
data/Gemfile
CHANGED
@@ -4,3 +4,21 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in charty.gemspec
|
6
6
|
gemspec
|
7
|
+
|
8
|
+
group :cruby do
|
9
|
+
gem "enumerable-statistics"
|
10
|
+
end
|
11
|
+
|
12
|
+
group :nmatrix do
|
13
|
+
gem "nmatrix"
|
14
|
+
end
|
15
|
+
|
16
|
+
group :numo do
|
17
|
+
gem "numo-narray"
|
18
|
+
end
|
19
|
+
|
20
|
+
group :python do
|
21
|
+
gem "matplotlib"
|
22
|
+
gem "numpy"
|
23
|
+
gem "pandas"
|
24
|
+
end
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# Charty - Visualizing your data in Ruby
|
2
2
|
|
3
|
-
|
3
|
+

|
4
|
+
[](https://badge.fury.io/rb/charty)
|
4
5
|
[](https://mybinder.org/v2/gh/red-data-tools/charty/master?filepath=iris_dataset.ipynb)
|
6
|
+
[](https://rubydoc.info/gems/charty)
|
5
7
|
|
6
8
|
Charty is open-source Ruby library for visualizing your data in a simple way.
|
7
9
|
In Charty, you need to write very few lines of code for representing what you want to do.
|
@@ -32,8 +34,8 @@ $ CONFIGURE_OPTS="--enable-shared" pyenv install 3.x.x
|
|
32
34
|
### With Matplotlib
|
33
35
|
|
34
36
|
```
|
35
|
-
|
36
|
-
|
37
|
+
gem install charty --pre
|
38
|
+
gem install matplotlib
|
37
39
|
sudo apt install python3-pip
|
38
40
|
sudo python3 -m pip install -U pip matplotlib
|
39
41
|
```
|
@@ -43,18 +45,184 @@ sudo python3 -m pip install -U pip matplotlib
|
|
43
45
|
e.g.
|
44
46
|
|
45
47
|
```
|
46
|
-
$ docker build -f ./Dockerfile.dev -t charty-dev:
|
47
|
-
$ docker run --rm -v $
|
48
|
-
$ docker run -it -v $
|
48
|
+
$ docker build -f ./Dockerfile.dev -t charty-dev:latest .
|
49
|
+
$ docker run --rm -v $(pwd):/charty charty-dev:latest bundle install
|
50
|
+
$ docker run --rm -it -v $(pwd):/charty charty-dev:latest ./bin/console
|
49
51
|
irb(main):001:0> Charty::VERSION
|
50
|
-
=> "0.
|
52
|
+
=> "0.2.2"
|
51
53
|
|
52
54
|
# When using jupyter notebook
|
53
|
-
$ docker run -it -v $
|
55
|
+
$ docker run --rm -it -v $(pwd):/charty -p 8888:8888 charty-dev:latest
|
54
56
|
```
|
55
57
|
|
56
58
|
## Usage
|
57
59
|
|
60
|
+
### Statistical plotting interface
|
61
|
+
|
62
|
+
Charty supports statistical plotting as Python's seaborn.
|
63
|
+
|
64
|
+
In the following examplles, we use the `penguins` dataset provided in red-datasets.
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
require "datasets"
|
68
|
+
|
69
|
+
penguins = Datasets::Penguins.new
|
70
|
+
```
|
71
|
+
|
72
|
+
#### A basic workflow
|
73
|
+
|
74
|
+
The following code shows a basic workflow of the visualization with Charty.
|
75
|
+
|
76
|
+
First you need to load the Charty library.
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
require "charty"
|
80
|
+
```
|
81
|
+
|
82
|
+
Next you msut have a dataset you want to visualize. Here, we use the penguins dataset provided in red-datasets library.
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
require "datasets"
|
86
|
+
penguins = Datasets::Penguins.new
|
87
|
+
```
|
88
|
+
|
89
|
+
Next you need to create a plotter object by a plotting method. Here, we use `scatter_plot` method to show the relationship
|
90
|
+
among `body_mass_g`, `flipper_length_mm`, and `species` columns in the penguins dataset.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
plot = Charty.scatter_plot(data: penguins, x: :body_mass_g, y: :flipper_length_mm, color: :species)
|
94
|
+
```
|
95
|
+
|
96
|
+
If you want to render and save this plotter object into an HTML file by plotly backend, you can do it like below.
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
Charty::Backends.use(:plotly) # select plotly backend
|
100
|
+
plot.save("scatter.html") # save the plot as an HTML file
|
101
|
+
```
|
102
|
+
|
103
|
+
When you already have prepared [playwright-ruby-client](https://github.com/YusukeIwaki/playwright-ruby-client),
|
104
|
+
you can render a plot into a PNG file by plotly backend by specifying a filename with `.png` extension.
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
plot.save("scatter.png")
|
108
|
+
```
|
109
|
+
|
110
|
+
#### Jupyter Notebook
|
111
|
+
|
112
|
+
If you use Charty on Jupyter Notebook with IRuby kerenl (a.k.a. IRuby notebook),
|
113
|
+
you can render the plot just evaluate a plotter object. For example, the code below shows a scatter plot figure in
|
114
|
+
the output area.
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
Charty::Backends.use(:plotly)
|
118
|
+
|
119
|
+
Charty.scatter_plot(data: penguins, x: :body_mass_g, y: :flipper_length_mm, color: :species)
|
120
|
+
```
|
121
|
+
|
122
|
+
Note that if you want to use the pyplot backend, you need to activate the integration between the pyplot backend and IRuby.
|
123
|
+
You can activate the integration by the following two lines.
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
Charty::Backends.use(:pyplot)
|
127
|
+
Charty::Backends::Pyplot.activate_iruby_integration
|
128
|
+
```
|
129
|
+
|
130
|
+
#### Bar plot
|
131
|
+
|
132
|
+
Charty's statistical bar plot shows the relationship between a categorical variable and estimated means of a numeric variable.
|
133
|
+
This plot automatically calculates mean estimation and its 95% confidence interval of the numeric variable.
|
134
|
+
|
135
|
+
When we specify the categorical varaible as x-axis, the plot draws a vertical bar chart.
|
136
|
+
Instead, when we specify the categorical variable as y-axis, the plot draws a horizontal bar chart.
|
137
|
+
|
138
|
+
The following code shows the relationship between species and the mean body masses of penguins in a vertical bar chart.
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
Charty.bar_plot(data: penguins, x: :species, y: :body_mass_g)
|
142
|
+
```
|
143
|
+
|
144
|
+

|
145
|
+
|
146
|
+
Exchanging x and y axes alternates the orientation of the resulting chart.
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
Charty.bar_plot(data: penguins, x: :body_mass_g, y: :species)
|
150
|
+
```
|
151
|
+
|
152
|
+

|
153
|
+
|
154
|
+
Adding color axis introduces color grouping in the bar plot.
|
155
|
+
|
156
|
+
```ruby
|
157
|
+
Charty.bar_plot(data: penguins, x: :species, y: :body_mass_g, color: :sex)
|
158
|
+
```
|
159
|
+
|
160
|
+

|
161
|
+
|
162
|
+
#### Box plot
|
163
|
+
|
164
|
+
Charty's statistical box plot shows distributions of a numeric variable per categories.
|
165
|
+
The distributions are showed by boxes with whiskers that characterized by five-number summary.
|
166
|
+
This plot automatically calculates five-number summary the numeric variable per categories.
|
167
|
+
|
168
|
+
When we specify the categorical varaible as x-axis, the plot draws a vertical box plot chart.
|
169
|
+
Instead, when we specify the categorical variable as y-axis, the plot draws a horizontal box plot chart.
|
170
|
+
|
171
|
+
The following code draws a vertical box plot to show distributions of penguins' body mass per species.
|
172
|
+
|
173
|
+
```ruby
|
174
|
+
Charty.box_plot(data: penguins, x: :species, y: :body_mass_g)
|
175
|
+
```
|
176
|
+
|
177
|
+

|
178
|
+
|
179
|
+
As `bar_plot` above, exchanging x and y axes alternates the orientation of the resulting chart.
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
Charty.box_plot(data: penguins, x: :body_mass_g, y: :species)
|
183
|
+
```
|
184
|
+
|
185
|
+

|
186
|
+
|
187
|
+
Adding color axis introduces color grouping in the box plot.
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
Charty.box_plot(data: penguins, x: :species, y: :body_mass_g, color: :sex)
|
191
|
+
```
|
192
|
+
|
193
|
+

|
194
|
+
|
195
|
+
#### Scatter plot
|
196
|
+
|
197
|
+
Charty's scatter plot shows the relationship between two numeric variables.
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
Charty.scatter_plot(data: penguins, x: :body_mass_g, y: flipper_length_mm)
|
201
|
+
```
|
202
|
+
|
203
|
+

|
204
|
+
|
205
|
+
Adding color axis introduces color grouping in the scatter plot.
|
206
|
+
The following example specifies `:species` variable in the color axis.
|
207
|
+
It shows the different species by the different colors.
|
208
|
+
|
209
|
+
```ruby
|
210
|
+
Charty.scatter_plot(data: penguins, x: :body_mass_g, y: flipper_length_mm, color: :species)
|
211
|
+
```
|
212
|
+
|
213
|
+

|
214
|
+
|
215
|
+
Moreover, size and style axes can be specified.
|
216
|
+
The following example specifies `:sex` variable in the style axis.
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
Charty.scatter_plot(data: penguins, x: :body_mass_g, y: flipper_length_mm, color: :species, style: :sex)
|
220
|
+
```
|
221
|
+
|
222
|
+

|
223
|
+
|
224
|
+
### Old-style plotting interface
|
225
|
+
|
58
226
|
```ruby
|
59
227
|
require 'charty'
|
60
228
|
charty = Charty::Plotter.new(:pyplot)
|
@@ -354,7 +522,7 @@ hist.render("sample_images/hist_pyplot.png")
|
|
354
522
|
|
355
523
|
#### Gruff
|
356
524
|
|
357
|
-
|
525
|
+

|
358
526
|
|
359
527
|
#### Rubyplot
|
360
528
|
|