charty 0.1.2.dev → 0.1.3.dev

Sign up to get free protection for your applications and to get access to all the features.
@@ -92,8 +92,8 @@
92
92
  }
93
93
  ],
94
94
  "source": [
95
- "boxplot = charty.to_boxplot(:price, :sales)\n",
96
- "boxplot.render('sample')"
95
+ "box_plot = charty.to_box_plot(:price, :sales)\n",
96
+ "box_plot.render('sample')"
97
97
  ]
98
98
  },
99
99
  {
@@ -180,8 +180,8 @@
180
180
  }
181
181
  ],
182
182
  "source": [
183
- "errorbar = charty.to_errorbar(:price, :sales)\n",
184
- "errorbar.render('sample')"
183
+ "error_bar = charty.to_error_bar(:price, :sales)\n",
184
+ "error_bar.render('sample')"
185
185
  ]
186
186
  },
187
187
  {
@@ -2,20 +2,9 @@
2
2
  "cells": [
3
3
  {
4
4
  "cell_type": "code",
5
- "execution_count": 10,
5
+ "execution_count": null,
6
6
  "metadata": {},
7
- "outputs": [
8
- {
9
- "data": {
10
- "text/plain": [
11
- "[:inline, \"module://matplotlib.backends.backend_inline\"]"
12
- ]
13
- },
14
- "execution_count": 10,
15
- "metadata": {},
16
- "output_type": "execute_result"
17
- }
18
- ],
7
+ "outputs": [],
19
8
  "source": [
20
9
  "require 'charty'\n",
21
10
  "\n",
@@ -95,8 +84,8 @@
95
84
  }
96
85
  ],
97
86
  "source": [
98
- "boxplot = charty.to_boxplot(:price, :sales)\n",
99
- "boxplot.render('sample')"
87
+ "box_plot = charty.to_box_plot(:price, :sales)\n",
88
+ "box_plot.render('sample')"
100
89
  ]
101
90
  },
102
91
  {
@@ -183,8 +172,8 @@
183
172
  }
184
173
  ],
185
174
  "source": [
186
- "errorbar = charty.to_errorbar(:price, :sales)\n",
187
- "errorbar.render('sample')"
175
+ "error_bar = charty.to_error_bar(:price, :sales)\n",
176
+ "error_bar.render('sample')"
188
177
  ]
189
178
  },
190
179
  {
@@ -157,14 +157,14 @@
157
157
  }
158
158
  ],
159
159
  "source": [
160
- "boxplot = charty.boxplot do\n",
160
+ "box_plot = charty.box_plot do\n",
161
161
  " data [[60,70,80,70,50], [100,40,20,80,70], [30, 10]]\n",
162
162
  " range x: 0..10, y: 1..100\n",
163
163
  " xlabel 'foo'\n",
164
164
  " ylabel 'bar'\n",
165
165
  " title 'box plot'\n",
166
166
  "end\n",
167
- "boxplot.render(\"sample_images/boxplot_matplot.png\")"
167
+ "box_plot.render(\"sample_images/box_plot_matplot.png\")"
168
168
  ]
169
169
  },
170
170
  {
@@ -206,7 +206,7 @@
206
206
  {
207
207
  "data": {
208
208
  "text/plain": [
209
- "#<Charty::Layout:0x00007fb2f4713870 @frontend=#<Charty::Matplot:0x00007fb2f4a2c048 @plot=<module 'matplotlib.pyplot' from '/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/pyplot.py'>, @series=[#<struct Charty::Series xs=0..10, ys=#<Enumerator: 0..1:step(0.1)>, zs=nil, xerr=nil, yerr=nil, label=\"sample1\">, #<struct Charty::Series xs=0..5, ys=#<Enumerator: 0..1:step(0.2)>, zs=nil, xerr=nil, yerr=nil, label=\"sample2\">, #<struct Charty::Series xs=[0, 1, 2, 3, 4], ys=[0, -0.1, -0.5, -0.5, 0.1], zs=nil, xerr=nil, yerr=nil, label=nil>]>, @layout=#<Charty::ArrayLayout:0x00007fb2f4713848 @array=[], @direction=:horizontal>>"
209
+ "#<Charty::Layout:0x00007f89d6291870 @frontend=#<Charty::Matplot:0x00007f89d713e580 @plot=<module 'matplotlib.pyplot' from '/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/pyplot.py'>, @series=[#<struct Charty::Series xs=0..10, ys=#<Enumerator: 0..1:step(0.1)>, zs=nil, xerr=nil, yerr=nil, label=\"sample1\">, #<struct Charty::Series xs=0..5, ys=#<Enumerator: 0..1:step(0.2)>, zs=nil, xerr=nil, yerr=nil, label=\"sample2\">, #<struct Charty::Series xs=[0, 1, 2, 3, 4], ys=[0, -0.1, -0.5, -0.5, 0.1], zs=nil, xerr=nil, yerr=nil, label=nil>]>, @layout=#<Charty::ArrayLayout:0x00007f89d62917f8 @array=[], @direction=:horizontal>>"
210
210
  ]
211
211
  },
212
212
  "execution_count": 8,
@@ -281,7 +281,7 @@
281
281
  },
282
282
  {
283
283
  "cell_type": "code",
284
- "execution_count": 11,
284
+ "execution_count": 13,
285
285
  "metadata": {},
286
286
  "outputs": [
287
287
  {
@@ -291,13 +291,13 @@
291
291
  "<Figure size 640x480 with 1 Axes>"
292
292
  ]
293
293
  },
294
- "execution_count": 11,
294
+ "execution_count": 13,
295
295
  "metadata": {},
296
296
  "output_type": "execute_result"
297
297
  }
298
298
  ],
299
299
  "source": [
300
- "errorbar = charty.errorbar do\n",
300
+ "error_bar = charty.error_bar do\n",
301
301
  " series [1,2,3,4], [1,4,9,16], xerr: [0.5,1.0,1.5,0.3], yerr: [0.6,0.2,0.8,0.1], label: 'label1'\n",
302
302
  " series [1,2,3,4], [16,9,4,1], label: 'label2'\n",
303
303
  " series [1,2,3,4,5,6,7,8], [14,14,14,14,14,14,14,14], label: 'label2', xerr: [0.5,1.0,1.5,0.3, 1.1, 1.2, 1.3, 1.4]\n",
@@ -305,12 +305,12 @@
305
305
  " xlabel 'x label' \n",
306
306
  " title 'errorbar'\n",
307
307
  "end\n",
308
- "errorbar.render(\"sample_images/errorbar_matplot.png\")"
308
+ "error_bar.render(\"sample_images/error_bar_matplot.png\")"
309
309
  ]
310
310
  },
311
311
  {
312
312
  "cell_type": "code",
313
- "execution_count": 12,
313
+ "execution_count": 14,
314
314
  "metadata": {},
315
315
  "outputs": [
316
316
  {
@@ -320,7 +320,7 @@
320
320
  "<Figure size 640x480 with 1 Axes>"
321
321
  ]
322
322
  },
323
- "execution_count": 12,
323
+ "execution_count": 14,
324
324
  "metadata": {},
325
325
  "output_type": "execute_result"
326
326
  }
@@ -340,7 +340,7 @@
340
340
  },
341
341
  {
342
342
  "cell_type": "code",
343
- "execution_count": 13,
343
+ "execution_count": 15,
344
344
  "metadata": {},
345
345
  "outputs": [
346
346
  {
@@ -350,7 +350,7 @@
350
350
  "<Figure size 640x480 with 1 Axes>"
351
351
  ]
352
352
  },
353
- "execution_count": 13,
353
+ "execution_count": 15,
354
354
  "metadata": {},
355
355
  "output_type": "execute_result"
356
356
  }
@@ -138,14 +138,14 @@
138
138
  }
139
139
  ],
140
140
  "source": [
141
- "boxplot = charty.boxplot do\n",
141
+ "box_plot = charty.box_plot do\n",
142
142
  " data [[60,70,80,70,50], [100,40,20,80,70], [30, 10]]\n",
143
143
  " range x: 0..10, y: 1..100\n",
144
144
  " xlabel 'foo'\n",
145
145
  " ylabel 'bar'\n",
146
146
  " title 'box plot'\n",
147
147
  "end\n",
148
- "boxplot.render(\"sample_images/boxplot_rubyplot.png\")"
148
+ "box_plot.render(\"sample_images/box_plot_rubyplot.png\")"
149
149
  ]
150
150
  },
151
151
  {
@@ -17,7 +17,8 @@ module Charty
17
17
  raise NotImplementedError
18
18
  end
19
19
 
20
- def render(context, filename)
20
+ def render(context, filename="")
21
+ FileUtils.mkdir_p(File.dirname(filename))
21
22
  plot(@plot, context).write(filename)
22
23
  end
23
24
 
@@ -44,7 +45,7 @@ module Charty
44
45
  when :barh
45
46
  # TODO: To implement
46
47
  raise NotImplementedError
47
- when :boxplot
48
+ when :box_plot
48
49
  # refs. https://github.com/topfunky/gruff/issues/155
49
50
  raise NotImplementedError
50
51
  when :bubble
@@ -67,7 +68,7 @@ module Charty
67
68
  p.data(data.label, data.xs.to_a, data.ys.to_a)
68
69
  end
69
70
  p
70
- when :errorbar
71
+ when :error_bar
71
72
  # refs. https://github.com/topfunky/gruff/issues/163
72
73
  raise NotImplementedError
73
74
  when :hist
@@ -31,7 +31,10 @@ module Charty
31
31
 
32
32
  def render(context, filename)
33
33
  plot(@plot, context)
34
- @plot.savefig(filename) if filename
34
+ if filename
35
+ FileUtils.mkdir_p(File.dirname(filename))
36
+ @plot.savefig(filename)
37
+ end
35
38
  @plot.show
36
39
  end
37
40
 
@@ -61,7 +64,7 @@ module Charty
61
64
  context.series.each do |data|
62
65
  plot.barh(data.xs.to_a.map(&:to_s), data.ys.to_a)
63
66
  end
64
- when :boxplot
67
+ when :box_plot
65
68
  plot.boxplot(context.data.to_a)
66
69
  when :bubble
67
70
  context.series.each do |data|
@@ -76,7 +79,7 @@ module Charty
76
79
  plot.scatter(data.xs.to_a, data.ys.to_a, label: data.label)
77
80
  end
78
81
  plot.legend()
79
- when :errorbar
82
+ when :error_bar
80
83
  context.series.each do |data|
81
84
  plot.errorbar(
82
85
  data.xs.to_a,
@@ -11,6 +11,9 @@ module Charty
11
11
  when :rubyplot
12
12
  require_relative "rubyplot"
13
13
  Charty::Rubyplot.new
14
+ when :chartjs
15
+ require_relative "chartjs"
16
+ Charty::Chartjs.new
14
17
  else
15
18
  raise NotImplementedError
16
19
  end
@@ -46,11 +49,11 @@ module Charty
46
49
  end
47
50
  end
48
51
 
49
- def to_boxplot(x, y, **args, &block)
52
+ def to_box_plot(x, y, **args, &block)
50
53
  serieses = table.to_a(x, y)
51
54
  xrange = 0..serieses.size
52
55
  yrange = (serieses.flatten.min - 1)..(serieses.flatten.max + 1)
53
- boxplot = boxplot do
56
+ box_plot = box_plot do
54
57
  data serieses
55
58
  range x: xrange, y: yrange
56
59
  xlabel x
@@ -94,12 +97,12 @@ module Charty
94
97
  end
95
98
  end
96
99
 
97
- def to_errorbar(x, y, **args, &block)
100
+ def to_error_bar(x, y, **args, &block)
98
101
  # TODO: It is not yet decided how to include data including xerror and yerror.
99
102
  seriesx, seriesy = *table.to_a(x, y)
100
103
  xrange = (seriesx.min)..(seriesx.max)
101
104
  yrange = (seriesy.min)..(seriesy.max)
102
- errorbar = errorbar do
105
+ error_bar = error_bar do
103
106
  series seriesx, seriesy
104
107
  range x: xrange, y: yrange
105
108
  xlabel x
@@ -129,8 +132,8 @@ module Charty
129
132
  context.apply(@frontend)
130
133
  end
131
134
 
132
- def boxplot(**args, &block)
133
- context = RenderContext.new :boxplot, **args, &block
135
+ def box_plot(**args, &block)
136
+ context = RenderContext.new :box_plot, **args, &block
134
137
  context.apply(@frontend)
135
138
  end
136
139
 
@@ -149,8 +152,8 @@ module Charty
149
152
  context.apply(@frontend)
150
153
  end
151
154
 
152
- def errorbar(**args, &block)
153
- context = RenderContext.new :errorbar, **args, &block
155
+ def error_bar(**args, &block)
156
+ context = RenderContext.new :error_bar, **args, &block
154
157
  context.apply(@frontend)
155
158
  end
156
159
 
@@ -24,7 +24,8 @@ module Charty
24
24
  @plot.show
25
25
  end
26
26
 
27
- def render(context, filename)
27
+ def render(context, filename="")
28
+ FileUtils.mkdir_p(File.dirname(filename))
28
29
  plot(@plot, context).write(filename)
29
30
  end
30
31
 
@@ -55,7 +56,7 @@ module Charty
55
56
  figure
56
57
  when :barh
57
58
  raise NotImplementedError
58
- when :boxplot
59
+ when :box_plot
59
60
  raise NotImplementedError
60
61
  when :bubble
61
62
  context.series.each do |data|
@@ -81,7 +82,7 @@ module Charty
81
82
  end
82
83
  end
83
84
  figure
84
- when :errorbar
85
+ when :error_bar
85
86
  # refs. https://github.com/SciRuby/rubyplot/issues/26
86
87
  raise NotImplementedError
87
88
  when :hist
@@ -1,5 +1,5 @@
1
1
  module Charty
2
- VERSION = "0.1.2-dev"
2
+ VERSION = "0.1.3-dev"
3
3
 
4
4
  module Version
5
5
  numbers, TAG = VERSION.split("-")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: charty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2.dev
4
+ version: 0.1.3.dev
5
5
  platform: ruby
6
6
  authors:
7
7
  - youchan
@@ -10,20 +10,20 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-04-16 00:00:00.000000000 Z
13
+ date: 2019-04-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: '1.16'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - "~>"
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: '1.16'
29
29
  - !ruby/object:Gem::Dependency
@@ -40,6 +40,20 @@ dependencies:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '10.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: matplotlib
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
43
57
  description: Visualizing your data in a simple way.
44
58
  email:
45
59
  - youchan01@gmail.com
@@ -52,7 +66,6 @@ files:
52
66
  - ".gitignore"
53
67
  - Gemfile
54
68
  - LICENSE
55
- - LICENSE.txt
56
69
  - README.md
57
70
  - Rakefile
58
71
  - bin/console
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 youchan
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.