daru-view 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +4 -0
  4. data/.rubocop.yml +122 -0
  5. data/.simplecov +3 -0
  6. data/.travis.yml +18 -0
  7. data/CHANGELOG.md +21 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/CONTRIBUTING.md +53 -0
  10. data/Gemfile +11 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +287 -0
  13. data/Rakefile +22 -0
  14. data/_config.yml +1 -0
  15. data/daru-view.gemspec +52 -0
  16. data/lib/assets/.keep +0 -0
  17. data/lib/daru/view.rb +127 -0
  18. data/lib/daru/view/adapters/datatables.rb +90 -0
  19. data/lib/daru/view/adapters/googlecharts.rb +180 -0
  20. data/lib/daru/view/adapters/googlecharts/data_table_iruby.rb +86 -0
  21. data/lib/daru/view/adapters/googlecharts/display.rb +54 -0
  22. data/lib/daru/view/adapters/googlecharts/iruby_notebook.rb +15 -0
  23. data/lib/daru/view/adapters/highcharts.rb +114 -0
  24. data/lib/daru/view/adapters/highcharts/core_ext/string.rb +10 -0
  25. data/lib/daru/view/adapters/highcharts/display.rb +58 -0
  26. data/lib/daru/view/adapters/highcharts/iruby_notebook.rb +29 -0
  27. data/lib/daru/view/adapters/highcharts/layout_helper_iruby.rb +76 -0
  28. data/lib/daru/view/adapters/js/googlecharts_js/google_visualr.js +44 -0
  29. data/lib/daru/view/adapters/js/googlecharts_js/loader.js +226 -0
  30. data/lib/daru/view/adapters/js/highcharts_js/adapters/mootools-adapter.js +13 -0
  31. data/lib/daru/view/adapters/js/highcharts_js/adapters/prototype-adapter.js +15 -0
  32. data/lib/daru/view/adapters/js/highcharts_js/highcharts-3d.js +74 -0
  33. data/lib/daru/view/adapters/js/highcharts_js/highcharts-more.js +64 -0
  34. data/lib/daru/view/adapters/js/highcharts_js/highcharts.js +399 -0
  35. data/lib/daru/view/adapters/js/highcharts_js/highstock.js +519 -0
  36. data/lib/daru/view/adapters/js/highcharts_js/modules/accessibility.js +48 -0
  37. data/lib/daru/view/adapters/js/highcharts_js/modules/annotations.js +14 -0
  38. data/lib/daru/view/adapters/js/highcharts_js/modules/boost.js +51 -0
  39. data/lib/daru/view/adapters/js/highcharts_js/modules/broken-axis.js +15 -0
  40. data/lib/daru/view/adapters/js/highcharts_js/modules/canvas-tools.js +133 -0
  41. data/lib/daru/view/adapters/js/highcharts_js/modules/data.js +26 -0
  42. data/lib/daru/view/adapters/js/highcharts_js/modules/drilldown.js +25 -0
  43. data/lib/daru/view/adapters/js/highcharts_js/modules/exporting.js +27 -0
  44. data/lib/daru/view/adapters/js/highcharts_js/modules/funnel.js +13 -0
  45. data/lib/daru/view/adapters/js/highcharts_js/modules/heatmap.js +25 -0
  46. data/lib/daru/view/adapters/js/highcharts_js/modules/no-data-to-display.js +12 -0
  47. data/lib/daru/view/adapters/js/highcharts_js/modules/offline-exporting.js +19 -0
  48. data/lib/daru/view/adapters/js/highcharts_js/modules/solid-gauge.js +14 -0
  49. data/lib/daru/view/adapters/js/highcharts_js/modules/treemap.js +31 -0
  50. data/lib/daru/view/adapters/js/highcharts_js/stock/adapters/mootools-adapter.js +13 -0
  51. data/lib/daru/view/adapters/js/highcharts_js/stock/adapters/prototype-adapter.js +15 -0
  52. data/lib/daru/view/adapters/js/highcharts_js/stock/highcharts-more.js +64 -0
  53. data/lib/daru/view/adapters/js/highcharts_js/stock/modules/exporting.js +27 -0
  54. data/lib/daru/view/adapters/js/highcharts_js/stock/modules/funnel.js +13 -0
  55. data/lib/daru/view/adapters/js/nyaplot_js/d3-downloadable.js +129 -0
  56. data/lib/daru/view/adapters/js/nyaplot_js/d3.min.js +5 -0
  57. data/lib/daru/view/adapters/js/nyaplot_js/nyaplot.js +5294 -0
  58. data/lib/daru/view/adapters/nyaplot.rb +62 -0
  59. data/lib/daru/view/adapters/nyaplot/display.rb +9 -0
  60. data/lib/daru/view/adapters/nyaplot/iruby_notebook.rb +22 -0
  61. data/lib/daru/view/app/rails/helpers/view_helper.rb +26 -0
  62. data/lib/daru/view/app/rails/railtie.rb +15 -0
  63. data/lib/daru/view/plot.rb +106 -0
  64. data/lib/daru/view/table.rb +99 -0
  65. data/lib/daru/view/templates/googlecharts/chart_div.erb +4 -0
  66. data/lib/daru/view/templates/googlecharts/init.inline.js.erb +16 -0
  67. data/lib/daru/view/templates/highcharts/init.inline.js.erb +16 -0
  68. data/lib/daru/view/templates/highcharts/static_html.erb +7 -0
  69. data/lib/daru/view/templates/nyaplot/init.inline.js.erb +16 -0
  70. data/lib/daru/view/templates/nyaplot/init_script.erb +3 -0
  71. data/lib/daru/view/version.rb +5 -0
  72. data/lib/tasks/.keep +0 -0
  73. data/lib/tasks/google_charts.rake +25 -0
  74. data/lib/tasks/high_charts.rake +60 -0
  75. data/lib/tasks/nyaplot.rake +25 -0
  76. data/spec/adapters/datatables_spec.rb +21 -0
  77. data/spec/adapters/googlecharts_spec.rb +34 -0
  78. data/spec/adapters/highcharts_spec.rb +177 -0
  79. data/spec/adapters/nyaplot_spec.rb +447 -0
  80. data/spec/app/rails/helpers/view_helpers_spec.rb +35 -0
  81. data/spec/dummy_iruby/.ipynb_checkpoints/Daru DataFrame and DataTables-checkpoint.ipynb +16091 -0
  82. data/spec/dummy_iruby/.ipynb_checkpoints/DataTables | basic examples-checkpoint.ipynb +6 -0
  83. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Line Chart-checkpoint.ipynb +1389 -0
  84. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Area Chart-checkpoint.ipynb +606 -0
  85. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Bar Chart-checkpoint.ipynb +1404 -0
  86. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Bubble Chart-checkpoint.ipynb +866 -0
  87. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Candlestick Chart-checkpoint.ipynb +607 -0
  88. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Combo Chart-checkpoint.ipynb +478 -0
  89. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Histogram-checkpoint.ipynb +1182 -0
  90. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Org Chart-checkpoint.ipynb +6 -0
  91. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Pie Chart-checkpoint.ipynb +6 -0
  92. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Stepped Area Chart-checkpoint.ipynb +699 -0
  93. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Timeline-checkpoint.ipynb +1523 -0
  94. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | Treemap-checkpoint.ipynb +650 -0
  95. data/spec/dummy_iruby/.ipynb_checkpoints/Google Chart | gauge-checkpoint.ipynb +477 -0
  96. data/spec/dummy_iruby/.ipynb_checkpoints/Google Charts | Basics-checkpoint.ipynb +1881 -0
  97. data/spec/dummy_iruby/.ipynb_checkpoints/Google Charts | Column Charts-checkpoint.ipynb +6 -0
  98. data/spec/dummy_iruby/.ipynb_checkpoints/Google Charts | Geo Charts examples-checkpoint.ipynb +791 -0
  99. data/spec/dummy_iruby/.ipynb_checkpoints/Google Charts | Scatter Chart-checkpoint.ipynb +1570 -0
  100. data/spec/dummy_iruby/.ipynb_checkpoints/GoolgeChart | Datatables-checkpoint.ipynb +1792 -0
  101. data/spec/dummy_iruby/.ipynb_checkpoints/HighCharts - Area chart-checkpoint.ipynb +1272 -0
  102. data/spec/dummy_iruby/.ipynb_checkpoints/HighCharts - Bar Chart-checkpoint.ipynb +877 -0
  103. data/spec/dummy_iruby/.ipynb_checkpoints/HighCharts - column charts-checkpoint.ipynb +1587 -0
  104. data/spec/dummy_iruby/.ipynb_checkpoints/HighCharts- Pie charts-checkpoint.ipynb +1126 -0
  105. data/spec/dummy_iruby/.ipynb_checkpoints/Highcharts - Combinations -checkpoint.ipynb +925 -0
  106. data/spec/dummy_iruby/.ipynb_checkpoints/Highcharts - Daynamic charts-checkpoint.ipynb +839 -0
  107. data/spec/dummy_iruby/.ipynb_checkpoints/Highcharts - line graphs-checkpoint.ipynb +1297 -0
  108. data/spec/dummy_iruby/.ipynb_checkpoints/Highcharts - line graphs2-checkpoint.ipynb +879 -0
  109. data/spec/dummy_iruby/.ipynb_checkpoints/Highcharts - scatter -bubble charts-checkpoint.ipynb +1071 -0
  110. data/spec/dummy_iruby/.ipynb_checkpoints/Highcharts | add_series method and highcharts examples-checkpoint.ipynb +1165 -0
  111. data/spec/dummy_iruby/.ipynb_checkpoints/Nyaplot basics | Daru Examples-checkpoint.ipynb +1383 -0
  112. data/spec/dummy_iruby/.ipynb_checkpoints/Nyaplot other examples-checkpoint.ipynb +6 -0
  113. data/spec/dummy_iruby/.ipynb_checkpoints/Nyaplot testing -checkpoint.ipynb +270 -0
  114. data/spec/dummy_iruby/.ipynb_checkpoints/Nyaplot | Creating Visualizations with DataFrame | from daru examples-checkpoint.ipynb +1716 -0
  115. data/spec/dummy_iruby/.ipynb_checkpoints/Pie Chart using HighCharts2-checkpoint.ipynb +784 -0
  116. data/spec/dummy_iruby/.ipynb_checkpoints/highcharts - Use HTML table (generated from daru) as data source-checkpoint.ipynb +956 -0
  117. data/spec/dummy_iruby/.ipynb_checkpoints/spec_testing-checkpoint.ipynb +1433 -0
  118. data/spec/dummy_iruby/Daru DataFrame and DataTables.ipynb +16091 -0
  119. data/spec/dummy_iruby/DataTables | basic examples.ipynb +15587 -0
  120. data/spec/dummy_iruby/Gemfile +33 -0
  121. data/spec/dummy_iruby/Google Chart | Line Chart.ipynb +1389 -0
  122. data/spec/dummy_iruby/Google Chart | Area Chart.ipynb +606 -0
  123. data/spec/dummy_iruby/Google Chart | Bar Chart.ipynb +1394 -0
  124. data/spec/dummy_iruby/Google Chart | Bubble Chart.ipynb +866 -0
  125. data/spec/dummy_iruby/Google Chart | Candlestick Chart.ipynb +607 -0
  126. data/spec/dummy_iruby/Google Chart | Combo Chart.ipynb +478 -0
  127. data/spec/dummy_iruby/Google Chart | Histogram.ipynb +1182 -0
  128. data/spec/dummy_iruby/Google Chart | Org Chart.ipynb +474 -0
  129. data/spec/dummy_iruby/Google Chart | Pie Chart.ipynb +1177 -0
  130. data/spec/dummy_iruby/Google Chart | Stepped Area Chart.ipynb +699 -0
  131. data/spec/dummy_iruby/Google Chart | Timeline.ipynb +1523 -0
  132. data/spec/dummy_iruby/Google Chart | Treemap.ipynb +659 -0
  133. data/spec/dummy_iruby/Google Chart | gauge.ipynb +477 -0
  134. data/spec/dummy_iruby/Google Charts | Basics.ipynb +1882 -0
  135. data/spec/dummy_iruby/Google Charts | Column Charts.ipynb +1138 -0
  136. data/spec/dummy_iruby/Google Charts | Geo Charts examples.ipynb +791 -0
  137. data/spec/dummy_iruby/Google Charts | Scatter Chart.ipynb +1570 -0
  138. data/spec/dummy_iruby/GoolgeChart | Datatables.ipynb +1801 -0
  139. data/spec/dummy_iruby/HighCharts - Area chart.ipynb +1272 -0
  140. data/spec/dummy_iruby/HighCharts - Bar Chart.ipynb +877 -0
  141. data/spec/dummy_iruby/HighCharts - column charts.ipynb +1587 -0
  142. data/spec/dummy_iruby/HighCharts- Pie charts.ipynb +1197 -0
  143. data/spec/dummy_iruby/Highcharts - Combinations .ipynb +925 -0
  144. data/spec/dummy_iruby/Highcharts - Daynamic charts.ipynb +839 -0
  145. data/spec/dummy_iruby/Highcharts - line graphs.ipynb +1297 -0
  146. data/spec/dummy_iruby/Highcharts - line graphs2.ipynb +879 -0
  147. data/spec/dummy_iruby/Highcharts - scatter -bubble charts.ipynb +1071 -0
  148. data/spec/dummy_iruby/Highcharts | add_series method and highcharts examples.ipynb +1228 -0
  149. data/spec/dummy_iruby/Nyaplot basics | Daru Examples.ipynb +1390 -0
  150. data/spec/dummy_iruby/Nyaplot other examples.ipynb +589 -0
  151. data/spec/dummy_iruby/Nyaplot testing .ipynb +270 -0
  152. data/spec/dummy_iruby/Nyaplot | Creating Visualizations with DataFrame | from daru examples.ipynb +1716 -0
  153. data/spec/dummy_iruby/Pie Chart using HighCharts2.ipynb +784 -0
  154. data/spec/dummy_iruby/highcharts - Use HTML table (generated from daru) as data source.ipynb +951 -0
  155. data/spec/dummy_iruby/spec_testing.ipynb +1433 -0
  156. data/spec/dummy_nanoc/Gemfile +12 -0
  157. data/spec/dummy_nanoc/README.md +40 -0
  158. data/spec/dummy_nanoc/Rules +90 -0
  159. data/spec/dummy_nanoc/content/googlecharts/index.html +29 -0
  160. data/spec/dummy_nanoc/content/highcharts/index.html +42 -0
  161. data/spec/dummy_nanoc/content/index.html +26 -0
  162. data/spec/dummy_nanoc/content/nyaplot/index.html +9 -0
  163. data/spec/dummy_nanoc/content/stylesheet.css +101 -0
  164. data/spec/dummy_nanoc/layouts/default.html +31 -0
  165. data/spec/dummy_nanoc/layouts/googlecharts_layout.html +30 -0
  166. data/spec/dummy_nanoc/layouts/highcharts_layout.html +30 -0
  167. data/spec/dummy_nanoc/layouts/nyaplot_layout.html +30 -0
  168. data/spec/dummy_nanoc/lib/default.rb +300 -0
  169. data/spec/dummy_nanoc/nanoc.yaml +90 -0
  170. data/spec/dummy_nanoc/output/googlecharts/index.html +390 -0
  171. data/spec/dummy_nanoc/output/highcharts/index.html +1153 -0
  172. data/spec/dummy_nanoc/output/index.html +87 -0
  173. data/spec/dummy_nanoc/output/nyaplot/index.html +135 -0
  174. data/spec/dummy_nanoc/output/stylesheet.css +101 -0
  175. data/spec/dummy_nanoc/tmp/nanoc/1029d67644815/checksums +0 -0
  176. data/spec/dummy_nanoc/tmp/nanoc/1029d67644815/compiled_content +2229 -0
  177. data/spec/dummy_nanoc/tmp/nanoc/1029d67644815/dependencies +5 -0
  178. data/spec/dummy_nanoc/tmp/nanoc/1029d67644815/outdatedness +0 -0
  179. data/spec/dummy_nanoc/tmp/nanoc/1029d67644815/rule_memory +0 -0
  180. data/spec/dummy_sinatra/Gemfile +9 -0
  181. data/spec/dummy_sinatra/README.md +15 -0
  182. data/spec/dummy_sinatra/app.rb +143 -0
  183. data/spec/dummy_sinatra/config.ru +0 -0
  184. data/spec/dummy_sinatra/views/googlecharts.erb +31 -0
  185. data/spec/dummy_sinatra/views/googlecharts_layout.erb +12 -0
  186. data/spec/dummy_sinatra/views/highcharts.erb +15 -0
  187. data/spec/dummy_sinatra/views/highcharts_layout.erb +12 -0
  188. data/spec/dummy_sinatra/views/index.erb +2 -0
  189. data/spec/dummy_sinatra/views/layout.erb +26 -0
  190. data/spec/dummy_sinatra/views/nyaplot.erb +13 -0
  191. data/spec/dummy_sinatra/views/nyaplot_layout.erb +14 -0
  192. data/spec/plot_spec.rb +86 -0
  193. data/spec/spec_helper.rb +11 -0
  194. metadata +568 -0
@@ -0,0 +1,1383 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {
7
+ "collapsed": false
8
+ },
9
+ "outputs": [
10
+ {
11
+ "name": "stderr",
12
+ "output_type": "stream",
13
+ "text": [
14
+ "\n",
15
+ "Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions.\n",
16
+ "\n",
17
+ "Install the mechanize gem version ~>2.7.5 for using mechanize functions.\n"
18
+ ]
19
+ },
20
+ {
21
+ "data": {
22
+ "text/plain": [
23
+ "true"
24
+ ]
25
+ },
26
+ "execution_count": 1,
27
+ "metadata": {},
28
+ "output_type": "execute_result"
29
+ }
30
+ ],
31
+ "source": [
32
+ "require 'daru/view'"
33
+ ]
34
+ },
35
+ {
36
+ "cell_type": "code",
37
+ "execution_count": 6,
38
+ "metadata": {
39
+ "collapsed": false
40
+ },
41
+ "outputs": [
42
+ {
43
+ "data": {
44
+ "application/javascript": [
45
+ "if(window['d3'] === undefined ||\n",
46
+ " window['Nyaplot'] === undefined){\n",
47
+ " var path = {\"d3\":\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min\",\"downloadable\":\"http://cdn.rawgit.com/domitry/d3-downloadable/master/d3-downloadable\"};\n",
48
+ "\n",
49
+ "\n",
50
+ "\n",
51
+ " var shim = {\"d3\":{\"exports\":\"d3\"},\"downloadable\":{\"exports\":\"downloadable\"}};\n",
52
+ "\n",
53
+ " require.config({paths: path, shim:shim});\n",
54
+ "\n",
55
+ "\n",
56
+ "require(['d3'], function(d3){window['d3']=d3;console.log('finished loading d3');require(['downloadable'], function(downloadable){window['downloadable']=downloadable;console.log('finished loading downloadable');\n",
57
+ "\n",
58
+ "\tvar script = d3.select(\"head\")\n",
59
+ "\t .append(\"script\")\n",
60
+ "\t .attr(\"src\", \"http://cdn.rawgit.com/domitry/Nyaplotjs/master/release/nyaplot.js\")\n",
61
+ "\t .attr(\"async\", true);\n",
62
+ "\n",
63
+ "\tscript[0][0].onload = script[0][0].onreadystatechange = function(){\n",
64
+ "\n",
65
+ "\n",
66
+ "\t var event = document.createEvent(\"HTMLEvents\");\n",
67
+ "\t event.initEvent(\"load_nyaplot\",false,false);\n",
68
+ "\t window.dispatchEvent(event);\n",
69
+ "\t console.log('Finished loading Nyaplotjs');\n",
70
+ "\n",
71
+ "\t};\n",
72
+ "\n",
73
+ "\n",
74
+ "});});\n",
75
+ "}\n"
76
+ ],
77
+ "text/plain": [
78
+ "\"if(window['d3'] === undefined ||\\n window['Nyaplot'] === undefined){\\n var path = {\\\"d3\\\":\\\"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min\\\",\\\"downloadable\\\":\\\"http://cdn.rawgit.com/domitry/d3-downloadable/master/d3-downloadable\\\"};\\n\\n\\n\\n var shim = {\\\"d3\\\":{\\\"exports\\\":\\\"d3\\\"},\\\"downloadable\\\":{\\\"exports\\\":\\\"downloadable\\\"}};\\n\\n require.config({paths: path, shim:shim});\\n\\n\\nrequire(['d3'], function(d3){window['d3']=d3;console.log('finished loading d3');require(['downloadable'], function(downloadable){window['downloadable']=downloadable;console.log('finished loading downloadable');\\n\\n\\tvar script = d3.select(\\\"head\\\")\\n\\t .append(\\\"script\\\")\\n\\t .attr(\\\"src\\\", \\\"http://cdn.rawgit.com/domitry/Nyaplotjs/master/release/nyaplot.js\\\")\\n\\t .attr(\\\"async\\\", true);\\n\\n\\tscript[0][0].onload = script[0][0].onreadystatechange = function(){\\n\\n\\n\\t var event = document.createEvent(\\\"HTMLEvents\\\");\\n\\t event.initEvent(\\\"load_nyaplot\\\",false,false);\\n\\t window.dispatchEvent(event);\\n\\t console.log('Finished loading Nyaplotjs');\\n\\n\\t};\\n\\n\\n});});\\n}\\n\""
79
+ ]
80
+ },
81
+ "metadata": {},
82
+ "output_type": "display_data"
83
+ },
84
+ {
85
+ "data": {
86
+ "text/plain": [
87
+ ":nyaplot"
88
+ ]
89
+ },
90
+ "execution_count": 6,
91
+ "metadata": {},
92
+ "output_type": "execute_result"
93
+ }
94
+ ],
95
+ "source": [
96
+ "Daru::View.plotting_library = :nyaplot"
97
+ ]
98
+ },
99
+ {
100
+ "cell_type": "markdown",
101
+ "metadata": {},
102
+ "source": [
103
+ "# Categorical Vector Visualization"
104
+ ]
105
+ },
106
+ {
107
+ "cell_type": "code",
108
+ "execution_count": 7,
109
+ "metadata": {
110
+ "collapsed": false
111
+ },
112
+ "outputs": [
113
+ {
114
+ "data": {
115
+ "text/html": [
116
+ "<table>\n",
117
+ " <tr>\n",
118
+ " <th colspan=\"2\">Daru::Vector(6):category</th>\n",
119
+ " </tr>\n",
120
+ " \n",
121
+ "\n",
122
+ " \n",
123
+ " <tr>\n",
124
+ " <td>0</td>\n",
125
+ " <td>a</td>\n",
126
+ " </tr>\n",
127
+ " \n",
128
+ " <tr>\n",
129
+ " <td>1</td>\n",
130
+ " <td>a</td>\n",
131
+ " </tr>\n",
132
+ " \n",
133
+ " <tr>\n",
134
+ " <td>2</td>\n",
135
+ " <td>a</td>\n",
136
+ " </tr>\n",
137
+ " \n",
138
+ " <tr>\n",
139
+ " <td>3</td>\n",
140
+ " <td>b</td>\n",
141
+ " </tr>\n",
142
+ " \n",
143
+ " <tr>\n",
144
+ " <td>4</td>\n",
145
+ " <td>b</td>\n",
146
+ " </tr>\n",
147
+ " \n",
148
+ " <tr>\n",
149
+ " <td>5</td>\n",
150
+ " <td>c</td>\n",
151
+ " </tr>\n",
152
+ " \n",
153
+ "\n",
154
+ " \n",
155
+ "</table>"
156
+ ],
157
+ "text/plain": [
158
+ "#<Daru::Vector(6):cataegory>\n",
159
+ " 0 a\n",
160
+ " 1 a\n",
161
+ " 2 a\n",
162
+ " 3 b\n",
163
+ " 4 b\n",
164
+ " 5 c"
165
+ ]
166
+ },
167
+ "execution_count": 7,
168
+ "metadata": {},
169
+ "output_type": "execute_result"
170
+ }
171
+ ],
172
+ "source": [
173
+ "dv = Daru::Vector.new [:a, :a, :a, :b, :b, :c], type: :category"
174
+ ]
175
+ },
176
+ {
177
+ "cell_type": "markdown",
178
+ "metadata": {},
179
+ "source": [
180
+ "### Bar graph\n",
181
+ "\n",
182
+ "##### 1. Frequency (count)"
183
+ ]
184
+ },
185
+ {
186
+ "cell_type": "code",
187
+ "execution_count": 8,
188
+ "metadata": {
189
+ "collapsed": false
190
+ },
191
+ "outputs": [
192
+ {
193
+ "data": {
194
+ "text/plain": [
195
+ "#<Daru::View::Plot:0x007fd05c935a10 @data=#<Daru::Vector(6):cataegory>\n",
196
+ " 0 a\n",
197
+ " 1 a\n",
198
+ " 2 a\n",
199
+ " 3 b\n",
200
+ " 4 b\n",
201
+ " 5 c, @options={:type=>:bar, :method=>:count}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x007fd05c935830 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05c92cc80 @properties={:type=>:bar, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"da25c1e7-7aad-4496-954d-2b4ebd49b531\"}, @xrange=[:a, :b, :c], @yrange=[0, 3]>], :options=>{}}>>"
202
+ ]
203
+ },
204
+ "execution_count": 8,
205
+ "metadata": {},
206
+ "output_type": "execute_result"
207
+ }
208
+ ],
209
+ "source": [
210
+ "bar_graph1 = Daru::View::Plot.new(dv, type: :bar)"
211
+ ]
212
+ },
213
+ {
214
+ "cell_type": "code",
215
+ "execution_count": 9,
216
+ "metadata": {
217
+ "collapsed": false
218
+ },
219
+ "outputs": [
220
+ {
221
+ "data": {
222
+ "text/plain": [
223
+ "Nyaplot::Plot"
224
+ ]
225
+ },
226
+ "execution_count": 9,
227
+ "metadata": {},
228
+ "output_type": "execute_result"
229
+ }
230
+ ],
231
+ "source": [
232
+ "bar_graph1.chart.class"
233
+ ]
234
+ },
235
+ {
236
+ "cell_type": "code",
237
+ "execution_count": 10,
238
+ "metadata": {
239
+ "collapsed": false
240
+ },
241
+ "outputs": [
242
+ {
243
+ "data": {
244
+ "text/html": [
245
+ "<div id='vis-a9909bc7-df51-4925-af63-73de4372f3be'></div>\n",
246
+ "<script>\n",
247
+ "(function(){\n",
248
+ " var render = function(){\n",
249
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"bar\",\"options\":{\"x\":\"data0\",\"y\":\"data1\"},\"data\":\"da25c1e7-7aad-4496-954d-2b4ebd49b531\"}],\"options\":{\"width\":700,\"xrange\":[\"a\",\"b\",\"c\"],\"yrange\":[0,3]}}],\"data\":{\"da25c1e7-7aad-4496-954d-2b4ebd49b531\":[{\"data0\":\"a\",\"data1\":3},{\"data0\":\"b\",\"data1\":2},{\"data0\":\"c\",\"data1\":1}]},\"extension\":[]}\n",
250
+ " var id_name = '#vis-a9909bc7-df51-4925-af63-73de4372f3be';\n",
251
+ " Nyaplot.core.parse(model, id_name);\n",
252
+ "\n",
253
+ " require(['downloadable'], function(downloadable){\n",
254
+ " var svg = d3.select(id_name).select(\"svg\");\n",
255
+ "\t if(!svg.empty())\n",
256
+ "\t svg.call(downloadable().filename('fig'));\n",
257
+ "\t});\n",
258
+ " };\n",
259
+ " if(window['Nyaplot']==undefined){\n",
260
+ " window.addEventListener('load_nyaplot', render, false);\n",
261
+ "\treturn;\n",
262
+ " } else {\n",
263
+ " render();\n",
264
+ " }\n",
265
+ "})();\n",
266
+ "</script>\n"
267
+ ],
268
+ "text/plain": [
269
+ "#<Nyaplot::Frame:0x007fd05c85e6f0 @properties={:panes=>[#<Nyaplot::Plot:0x007fd05c935830 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05c92cc80 @properties={:type=>:bar, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"da25c1e7-7aad-4496-954d-2b4ebd49b531\"}, @xrange=[:a, :b, :c], @yrange=[0, 3]>], :options=>{:width=>700, :xrange=>[:a, :b, :c], :yrange=>[0, 3]}}>], :data=>{\"da25c1e7-7aad-4496-954d-2b4ebd49b531\"=>#<Nyaplot::DataFrame:0x007fd05c92e828 @name=\"da25c1e7-7aad-4496-954d-2b4ebd49b531\", @rows=[{:data0=>:a, :data1=>3}, {:data0=>:b, :data1=>2}, {:data0=>:c, :data1=>1}]>}, :extension=>[]}>"
270
+ ]
271
+ },
272
+ "metadata": {},
273
+ "output_type": "display_data"
274
+ }
275
+ ],
276
+ "source": [
277
+ "bar_graph1.show_in_iruby"
278
+ ]
279
+ },
280
+ {
281
+ "cell_type": "code",
282
+ "execution_count": 11,
283
+ "metadata": {
284
+ "collapsed": false
285
+ },
286
+ "outputs": [
287
+ {
288
+ "data": {
289
+ "text/plain": [
290
+ ":category"
291
+ ]
292
+ },
293
+ "execution_count": 11,
294
+ "metadata": {},
295
+ "output_type": "execute_result"
296
+ }
297
+ ],
298
+ "source": [
299
+ "dv = Daru::Vector.new ['III']*10 + ['II']*5 + ['I']*5, type: :category, categories: ['I', 'II', 'III']\n",
300
+ "dv.type"
301
+ ]
302
+ },
303
+ {
304
+ "cell_type": "code",
305
+ "execution_count": 12,
306
+ "metadata": {
307
+ "collapsed": false
308
+ },
309
+ "outputs": [
310
+ {
311
+ "data": {
312
+ "text/plain": [
313
+ "#<Daru::View::Plot:0x007fd05b2faf20 @data=#<Daru::Vector(20):cataegory>\n",
314
+ " 0 III\n",
315
+ " 1 III\n",
316
+ " 2 III\n",
317
+ " 3 III\n",
318
+ " 4 III\n",
319
+ " 5 III\n",
320
+ " 6 III\n",
321
+ " 7 III\n",
322
+ " 8 III\n",
323
+ " 9 III\n",
324
+ " 10 II\n",
325
+ " 11 II\n",
326
+ " 12 II\n",
327
+ " 13 II\n",
328
+ " 14 II\n",
329
+ " ... ..., @options={:type=>:bar, :method=>:count}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x007fd05b2fae30 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05b2f90d0 @properties={:type=>:bar, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"9e71388d-9a02-42cd-adcc-fd532045edf3\"}, @xrange=[\"I\", \"II\", \"III\"], @yrange=[0, 10]>], :options=>{}}>>"
330
+ ]
331
+ },
332
+ "execution_count": 12,
333
+ "metadata": {},
334
+ "output_type": "execute_result"
335
+ }
336
+ ],
337
+ "source": [
338
+ "bar_graph2 = Daru::View::Plot.new(dv, type: :bar)"
339
+ ]
340
+ },
341
+ {
342
+ "cell_type": "code",
343
+ "execution_count": 13,
344
+ "metadata": {
345
+ "collapsed": false
346
+ },
347
+ "outputs": [
348
+ {
349
+ "data": {
350
+ "text/plain": [
351
+ "Daru::View::Plot"
352
+ ]
353
+ },
354
+ "execution_count": 13,
355
+ "metadata": {},
356
+ "output_type": "execute_result"
357
+ }
358
+ ],
359
+ "source": [
360
+ "bar_graph2.class"
361
+ ]
362
+ },
363
+ {
364
+ "cell_type": "code",
365
+ "execution_count": 14,
366
+ "metadata": {
367
+ "collapsed": false
368
+ },
369
+ "outputs": [
370
+ {
371
+ "data": {
372
+ "text/plain": [
373
+ "Nyaplot::Plot"
374
+ ]
375
+ },
376
+ "execution_count": 14,
377
+ "metadata": {},
378
+ "output_type": "execute_result"
379
+ }
380
+ ],
381
+ "source": [
382
+ "bar_graph2.chart.class"
383
+ ]
384
+ },
385
+ {
386
+ "cell_type": "code",
387
+ "execution_count": 15,
388
+ "metadata": {
389
+ "collapsed": false
390
+ },
391
+ "outputs": [
392
+ {
393
+ "data": {
394
+ "text/html": [
395
+ "<div id='vis-06549f53-653c-4dc4-a7fe-d0ceb3a80658'></div>\n",
396
+ "<script>\n",
397
+ "(function(){\n",
398
+ " var render = function(){\n",
399
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"bar\",\"options\":{\"x\":\"data0\",\"y\":\"data1\"},\"data\":\"9e71388d-9a02-42cd-adcc-fd532045edf3\"}],\"options\":{\"x_label\":\"Cat\",\"y_label\":\"Frequency\",\"width\":700,\"xrange\":[\"I\",\"II\",\"III\"],\"yrange\":[0,10]}}],\"data\":{\"9e71388d-9a02-42cd-adcc-fd532045edf3\":[{\"data0\":\"I\",\"data1\":5},{\"data0\":\"II\",\"data1\":5},{\"data0\":\"III\",\"data1\":10}]},\"extension\":[]}\n",
400
+ " var id_name = '#vis-06549f53-653c-4dc4-a7fe-d0ceb3a80658';\n",
401
+ " Nyaplot.core.parse(model, id_name);\n",
402
+ "\n",
403
+ " require(['downloadable'], function(downloadable){\n",
404
+ " var svg = d3.select(id_name).select(\"svg\");\n",
405
+ "\t if(!svg.empty())\n",
406
+ "\t svg.call(downloadable().filename('fig'));\n",
407
+ "\t});\n",
408
+ " };\n",
409
+ " if(window['Nyaplot']==undefined){\n",
410
+ " window.addEventListener('load_nyaplot', render, false);\n",
411
+ "\treturn;\n",
412
+ " } else {\n",
413
+ " render();\n",
414
+ " }\n",
415
+ "})();\n",
416
+ "</script>\n"
417
+ ],
418
+ "text/plain": [
419
+ "#<Nyaplot::Plot:0x007fd05b2fae30 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05b2f90d0 @properties={:type=>:bar, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"9e71388d-9a02-42cd-adcc-fd532045edf3\"}, @xrange=[\"I\", \"II\", \"III\"], @yrange=[0, 10]>], :options=>{:x_label=>\"Cat\", :y_label=>\"Frequency\", :width=>700, :xrange=>[\"I\", \"II\", \"III\"], :yrange=>[0, 10]}}>"
420
+ ]
421
+ },
422
+ "execution_count": 15,
423
+ "metadata": {},
424
+ "output_type": "execute_result"
425
+ }
426
+ ],
427
+ "source": [
428
+ "# Nyaplot methods will work.Since #chart is Nyaplot::Plot class object\n",
429
+ "bar_graph2.chart.x_label 'Cat'\n",
430
+ "bar_graph2.chart.y_label 'Frequency'"
431
+ ]
432
+ },
433
+ {
434
+ "cell_type": "code",
435
+ "execution_count": 16,
436
+ "metadata": {
437
+ "collapsed": false
438
+ },
439
+ "outputs": [
440
+ {
441
+ "data": {
442
+ "text/html": [
443
+ "<div id='vis-39949ceb-290a-46cb-bc6f-4a7c37f15ed5'></div>\n",
444
+ "<script>\n",
445
+ "(function(){\n",
446
+ " var render = function(){\n",
447
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"bar\",\"options\":{\"x\":\"data0\",\"y\":\"data1\"},\"data\":\"9e71388d-9a02-42cd-adcc-fd532045edf3\"}],\"options\":{\"x_label\":\"Cat\",\"y_label\":\"Frequency\",\"width\":700,\"xrange\":[\"I\",\"II\",\"III\"],\"yrange\":[0,10]}}],\"data\":{\"9e71388d-9a02-42cd-adcc-fd532045edf3\":[{\"data0\":\"I\",\"data1\":5},{\"data0\":\"II\",\"data1\":5},{\"data0\":\"III\",\"data1\":10}]},\"extension\":[]}\n",
448
+ " var id_name = '#vis-39949ceb-290a-46cb-bc6f-4a7c37f15ed5';\n",
449
+ " Nyaplot.core.parse(model, id_name);\n",
450
+ "\n",
451
+ " require(['downloadable'], function(downloadable){\n",
452
+ " var svg = d3.select(id_name).select(\"svg\");\n",
453
+ "\t if(!svg.empty())\n",
454
+ "\t svg.call(downloadable().filename('fig'));\n",
455
+ "\t});\n",
456
+ " };\n",
457
+ " if(window['Nyaplot']==undefined){\n",
458
+ " window.addEventListener('load_nyaplot', render, false);\n",
459
+ "\treturn;\n",
460
+ " } else {\n",
461
+ " render();\n",
462
+ " }\n",
463
+ "})();\n",
464
+ "</script>\n"
465
+ ],
466
+ "text/plain": [
467
+ "#<Nyaplot::Plot:0x007fd05b2fae30 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05b2f90d0 @properties={:type=>:bar, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"9e71388d-9a02-42cd-adcc-fd532045edf3\"}, @xrange=[\"I\", \"II\", \"III\"], @yrange=[0, 10]>], :options=>{:x_label=>\"Cat\", :y_label=>\"Frequency\", :width=>700, :xrange=>[\"I\", \"II\", \"III\"], :yrange=>[0, 10]}}>"
468
+ ]
469
+ },
470
+ "execution_count": 16,
471
+ "metadata": {},
472
+ "output_type": "execute_result"
473
+ }
474
+ ],
475
+ "source": [
476
+ "bar_graph2.chart # or bar_graph2.show_in_iruby"
477
+ ]
478
+ },
479
+ {
480
+ "cell_type": "markdown",
481
+ "metadata": {},
482
+ "source": [
483
+ "#### 2. Percentage"
484
+ ]
485
+ },
486
+ {
487
+ "cell_type": "code",
488
+ "execution_count": 17,
489
+ "metadata": {
490
+ "collapsed": false
491
+ },
492
+ "outputs": [
493
+ {
494
+ "data": {
495
+ "text/plain": [
496
+ "#<Daru::View::Plot:0x007fd05c34a678 @data=#<Daru::Vector(20):cataegory>\n",
497
+ " 0 III\n",
498
+ " 1 III\n",
499
+ " 2 III\n",
500
+ " 3 III\n",
501
+ " 4 III\n",
502
+ " 5 III\n",
503
+ " 6 III\n",
504
+ " 7 III\n",
505
+ " 8 III\n",
506
+ " 9 III\n",
507
+ " 10 II\n",
508
+ " 11 II\n",
509
+ " 12 II\n",
510
+ " 13 II\n",
511
+ " 14 II\n",
512
+ " ... ..., @options={:type=>:bar, :method=>:percentage}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x007fd05c34be10 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05b29a030 @properties={:type=>:bar, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"decb6897-b99b-420e-861d-bbe7a8375714\"}, @xrange=[\"I\", \"II\", \"III\"], @yrange=[0, 50.0]>], :options=>{:yrange=>[0, 100]}}>>"
513
+ ]
514
+ },
515
+ "execution_count": 17,
516
+ "metadata": {},
517
+ "output_type": "execute_result"
518
+ }
519
+ ],
520
+ "source": [
521
+ "bar_graph2_per = Daru::View::Plot.new(dv, type: :bar, method: :percentage)"
522
+ ]
523
+ },
524
+ {
525
+ "cell_type": "code",
526
+ "execution_count": 18,
527
+ "metadata": {
528
+ "collapsed": false
529
+ },
530
+ "outputs": [
531
+ {
532
+ "data": {
533
+ "text/html": [
534
+ "<div id='vis-d7b0494c-0239-442a-ac66-30ab74e04196'></div>\n",
535
+ "<script>\n",
536
+ "(function(){\n",
537
+ " var render = function(){\n",
538
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"bar\",\"options\":{\"x\":\"data0\",\"y\":\"data1\"},\"data\":\"decb6897-b99b-420e-861d-bbe7a8375714\"}],\"options\":{\"yrange\":[0,100],\"x_label\":\"Categories\",\"y_label\":\"Percentage (%)\",\"width\":700,\"xrange\":[\"I\",\"II\",\"III\"]}}],\"data\":{\"decb6897-b99b-420e-861d-bbe7a8375714\":[{\"data0\":\"I\",\"data1\":25.0},{\"data0\":\"II\",\"data1\":25.0},{\"data0\":\"III\",\"data1\":50.0}]},\"extension\":[]}\n",
539
+ " var id_name = '#vis-d7b0494c-0239-442a-ac66-30ab74e04196';\n",
540
+ " Nyaplot.core.parse(model, id_name);\n",
541
+ "\n",
542
+ " require(['downloadable'], function(downloadable){\n",
543
+ " var svg = d3.select(id_name).select(\"svg\");\n",
544
+ "\t if(!svg.empty())\n",
545
+ "\t svg.call(downloadable().filename('fig'));\n",
546
+ "\t});\n",
547
+ " };\n",
548
+ " if(window['Nyaplot']==undefined){\n",
549
+ " window.addEventListener('load_nyaplot', render, false);\n",
550
+ "\treturn;\n",
551
+ " } else {\n",
552
+ " render();\n",
553
+ " }\n",
554
+ "})();\n",
555
+ "</script>\n"
556
+ ],
557
+ "text/plain": [
558
+ "#<Nyaplot::Frame:0x007fd05bb58eb0 @properties={:panes=>[#<Nyaplot::Plot:0x007fd05c34be10 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05b29a030 @properties={:type=>:bar, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"decb6897-b99b-420e-861d-bbe7a8375714\"}, @xrange=[\"I\", \"II\", \"III\"], @yrange=[0, 50.0]>], :options=>{:yrange=>[0, 100], :x_label=>\"Categories\", :y_label=>\"Percentage (%)\", :width=>700, :xrange=>[\"I\", \"II\", \"III\"]}}>], :data=>{\"decb6897-b99b-420e-861d-bbe7a8375714\"=>#<Nyaplot::DataFrame:0x007fd05b29ab70 @name=\"decb6897-b99b-420e-861d-bbe7a8375714\", @rows=[{:data0=>\"I\", :data1=>25.0}, {:data0=>\"II\", :data1=>25.0}, {:data0=>\"III\", :data1=>50.0}]>}, :extension=>[]}>"
559
+ ]
560
+ },
561
+ "metadata": {},
562
+ "output_type": "display_data"
563
+ }
564
+ ],
565
+ "source": [
566
+ "bar_graph2_per.chart.x_label 'Categories'\n",
567
+ "bar_graph2_per.chart.y_label 'Percentage (%)'\n",
568
+ "bar_graph2_per.show_in_iruby"
569
+ ]
570
+ },
571
+ {
572
+ "cell_type": "markdown",
573
+ "metadata": {},
574
+ "source": [
575
+ "#### 3. Fraction"
576
+ ]
577
+ },
578
+ {
579
+ "cell_type": "code",
580
+ "execution_count": 19,
581
+ "metadata": {
582
+ "collapsed": false
583
+ },
584
+ "outputs": [
585
+ {
586
+ "data": {
587
+ "text/plain": [
588
+ "#<Daru::View::Plot:0x007fd05ca92c28 @data=#<Daru::Vector(20):cataegory>\n",
589
+ " 0 III\n",
590
+ " 1 III\n",
591
+ " 2 III\n",
592
+ " 3 III\n",
593
+ " 4 III\n",
594
+ " 5 III\n",
595
+ " 6 III\n",
596
+ " 7 III\n",
597
+ " 8 III\n",
598
+ " 9 III\n",
599
+ " 10 II\n",
600
+ " 11 II\n",
601
+ " 12 II\n",
602
+ " 13 II\n",
603
+ " 14 II\n",
604
+ " ... ..., @options={:type=>:bar, :method=>:fraction}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x007fd05ca92bb0 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05ca91850 @properties={:type=>:bar, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"017196d6-46a0-47c8-a234-bb2c67fa8c0c\"}, @xrange=[\"I\", \"II\", \"III\"], @yrange=[0, 0.5]>], :options=>{:yrange=>[0, 1]}}>>"
605
+ ]
606
+ },
607
+ "execution_count": 19,
608
+ "metadata": {},
609
+ "output_type": "execute_result"
610
+ }
611
+ ],
612
+ "source": [
613
+ "bar_graph2_frac = Daru::View::Plot.new(dv, type: :bar, method: :fraction)"
614
+ ]
615
+ },
616
+ {
617
+ "cell_type": "code",
618
+ "execution_count": 20,
619
+ "metadata": {
620
+ "collapsed": false
621
+ },
622
+ "outputs": [
623
+ {
624
+ "data": {
625
+ "text/html": [
626
+ "<div id='vis-24075e1a-c2c6-418c-a960-1226d92ee0b2'></div>\n",
627
+ "<script>\n",
628
+ "(function(){\n",
629
+ " var render = function(){\n",
630
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"bar\",\"options\":{\"x\":\"data0\",\"y\":\"data1\"},\"data\":\"017196d6-46a0-47c8-a234-bb2c67fa8c0c\"}],\"options\":{\"yrange\":[0,1],\"y_label\":\"Fraction\",\"width\":700,\"xrange\":[\"I\",\"II\",\"III\"]}}],\"data\":{\"017196d6-46a0-47c8-a234-bb2c67fa8c0c\":[{\"data0\":\"I\",\"data1\":0.25},{\"data0\":\"II\",\"data1\":0.25},{\"data0\":\"III\",\"data1\":0.5}]},\"extension\":[]}\n",
631
+ " var id_name = '#vis-24075e1a-c2c6-418c-a960-1226d92ee0b2';\n",
632
+ " Nyaplot.core.parse(model, id_name);\n",
633
+ "\n",
634
+ " require(['downloadable'], function(downloadable){\n",
635
+ " var svg = d3.select(id_name).select(\"svg\");\n",
636
+ "\t if(!svg.empty())\n",
637
+ "\t svg.call(downloadable().filename('fig'));\n",
638
+ "\t});\n",
639
+ " };\n",
640
+ " if(window['Nyaplot']==undefined){\n",
641
+ " window.addEventListener('load_nyaplot', render, false);\n",
642
+ "\treturn;\n",
643
+ " } else {\n",
644
+ " render();\n",
645
+ " }\n",
646
+ "})();\n",
647
+ "</script>\n"
648
+ ],
649
+ "text/plain": [
650
+ "#<Nyaplot::Frame:0x007fd05ca42d68 @properties={:panes=>[#<Nyaplot::Plot:0x007fd05ca92bb0 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05ca91850 @properties={:type=>:bar, :options=>{:x=>\"data0\", :y=>\"data1\"}, :data=>\"017196d6-46a0-47c8-a234-bb2c67fa8c0c\"}, @xrange=[\"I\", \"II\", \"III\"], @yrange=[0, 0.5]>], :options=>{:yrange=>[0, 1], :y_label=>\"Fraction\", :width=>700, :xrange=>[\"I\", \"II\", \"III\"]}}>], :data=>{\"017196d6-46a0-47c8-a234-bb2c67fa8c0c\"=>#<Nyaplot::DataFrame:0x007fd05ca91f30 @name=\"017196d6-46a0-47c8-a234-bb2c67fa8c0c\", @rows=[{:data0=>\"I\", :data1=>0.25}, {:data0=>\"II\", :data1=>0.25}, {:data0=>\"III\", :data1=>0.5}]>}, :extension=>[]}>"
651
+ ]
652
+ },
653
+ "metadata": {},
654
+ "output_type": "display_data"
655
+ }
656
+ ],
657
+ "source": [
658
+ "# bar_graph2_frac.chart.x_label 'Categories'\n",
659
+ "bar_graph2_frac.chart.y_label 'Fraction'\n",
660
+ "bar_graph2_frac.show_in_iruby"
661
+ ]
662
+ },
663
+ {
664
+ "cell_type": "markdown",
665
+ "metadata": {},
666
+ "source": [
667
+ "# Categorical data visualization in Dataframe\n",
668
+ "### Bar Graph"
669
+ ]
670
+ },
671
+ {
672
+ "cell_type": "code",
673
+ "execution_count": 21,
674
+ "metadata": {
675
+ "collapsed": false
676
+ },
677
+ "outputs": [
678
+ {
679
+ "data": {
680
+ "text/plain": [
681
+ ":category"
682
+ ]
683
+ },
684
+ "execution_count": 21,
685
+ "metadata": {},
686
+ "output_type": "execute_result"
687
+ }
688
+ ],
689
+ "source": [
690
+ "df = Daru::DataFrame.new({\n",
691
+ " a: [1, 2, 4, -2, 5, 23, 0],\n",
692
+ " b: [3, 1, 3, -6, 2, 1, 0],\n",
693
+ " c: ['I', 'II', 'I', 'III', 'I', 'III', 'II']\n",
694
+ " })\n",
695
+ "df.to_category :c\n",
696
+ "df[:c].type"
697
+ ]
698
+ },
699
+ {
700
+ "cell_type": "code",
701
+ "execution_count": 22,
702
+ "metadata": {
703
+ "collapsed": false
704
+ },
705
+ "outputs": [
706
+ {
707
+ "data": {
708
+ "text/plain": [
709
+ "#<Daru::View::Plot:0x007fd05bb12140 @data=#<Daru::DataFrame(7x3)>\n",
710
+ " a b c\n",
711
+ " 0 1 3 I\n",
712
+ " 1 2 1 II\n",
713
+ " 2 4 3 I\n",
714
+ " 3 -2 -6 III\n",
715
+ " 4 5 2 I\n",
716
+ " 5 23 1 III\n",
717
+ " 6 0 0 II, @options={:type=>:bar, :x=>:c}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x007fd05bb12028 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05bb01cc8 @properties={:type=>:bar, :options=>{:value=>:c}, :data=>\"dc767bc5-1edb-4065-a450-a9a3f4241eac\"}, @xrange=[\"I\", \"II\", \"III\"], @yrange=[0, 7]>], :options=>{}}>>"
718
+ ]
719
+ },
720
+ "execution_count": 22,
721
+ "metadata": {},
722
+ "output_type": "execute_result"
723
+ }
724
+ ],
725
+ "source": [
726
+ "bar_graph3 = Daru::View::Plot.new(df, type: :bar, x: :c)"
727
+ ]
728
+ },
729
+ {
730
+ "cell_type": "code",
731
+ "execution_count": 23,
732
+ "metadata": {
733
+ "collapsed": false
734
+ },
735
+ "outputs": [
736
+ {
737
+ "data": {
738
+ "text/html": [
739
+ "<div id='vis-703fc484-9142-435a-845d-9b86f5ed0622'></div>\n",
740
+ "<script>\n",
741
+ "(function(){\n",
742
+ " var render = function(){\n",
743
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"bar\",\"options\":{\"value\":\"c\"},\"data\":\"dc767bc5-1edb-4065-a450-a9a3f4241eac\"}],\"options\":{\"width\":700,\"xrange\":[\"I\",\"II\",\"III\"],\"yrange\":[0,7]}}],\"data\":{\"dc767bc5-1edb-4065-a450-a9a3f4241eac\":[{\"a\":1,\"b\":3,\"c\":\"I\"},{\"a\":2,\"b\":1,\"c\":\"II\"},{\"a\":4,\"b\":3,\"c\":\"I\"},{\"a\":-2,\"b\":-6,\"c\":\"III\"},{\"a\":5,\"b\":2,\"c\":\"I\"},{\"a\":23,\"b\":1,\"c\":\"III\"},{\"a\":0,\"b\":0,\"c\":\"II\"}]},\"extension\":[]}\n",
744
+ " var id_name = '#vis-703fc484-9142-435a-845d-9b86f5ed0622';\n",
745
+ " Nyaplot.core.parse(model, id_name);\n",
746
+ "\n",
747
+ " require(['downloadable'], function(downloadable){\n",
748
+ " var svg = d3.select(id_name).select(\"svg\");\n",
749
+ "\t if(!svg.empty())\n",
750
+ "\t svg.call(downloadable().filename('fig'));\n",
751
+ "\t});\n",
752
+ " };\n",
753
+ " if(window['Nyaplot']==undefined){\n",
754
+ " window.addEventListener('load_nyaplot', render, false);\n",
755
+ "\treturn;\n",
756
+ " } else {\n",
757
+ " render();\n",
758
+ " }\n",
759
+ "})();\n",
760
+ "</script>\n"
761
+ ],
762
+ "text/plain": [
763
+ "#<Nyaplot::Frame:0x007fd05c2cace8 @properties={:panes=>[#<Nyaplot::Plot:0x007fd05bb12028 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05bb01cc8 @properties={:type=>:bar, :options=>{:value=>:c}, :data=>\"dc767bc5-1edb-4065-a450-a9a3f4241eac\"}, @xrange=[\"I\", \"II\", \"III\"], @yrange=[0, 7]>], :options=>{:width=>700, :xrange=>[\"I\", \"II\", \"III\"], :yrange=>[0, 7]}}>], :data=>{\"dc767bc5-1edb-4065-a450-a9a3f4241eac\"=>#<Nyaplot::DataFrame:0x007fd05bb022b8 @name=\"dc767bc5-1edb-4065-a450-a9a3f4241eac\", @rows=[{:a=>1, :b=>3, :c=>\"I\"}, {:a=>2, :b=>1, :c=>\"II\"}, {:a=>4, :b=>3, :c=>\"I\"}, {:a=>-2, :b=>-6, :c=>\"III\"}, {:a=>5, :b=>2, :c=>\"I\"}, {:a=>23, :b=>1, :c=>\"III\"}, {:a=>0, :b=>0, :c=>\"II\"}]>}, :extension=>[]}>"
764
+ ]
765
+ },
766
+ "metadata": {},
767
+ "output_type": "display_data"
768
+ }
769
+ ],
770
+ "source": [
771
+ "bar_graph3.show_in_iruby"
772
+ ]
773
+ },
774
+ {
775
+ "cell_type": "markdown",
776
+ "metadata": {},
777
+ "source": [
778
+ "### Scatter plot categorized by categorical variable¶\n",
779
+ "#### Plots can be categorized by\n",
780
+ "\n",
781
+ "- Color\n",
782
+ "- Size\n",
783
+ "- Shape"
784
+ ]
785
+ },
786
+ {
787
+ "cell_type": "code",
788
+ "execution_count": 24,
789
+ "metadata": {
790
+ "collapsed": false
791
+ },
792
+ "outputs": [
793
+ {
794
+ "data": {
795
+ "text/plain": [
796
+ ":category"
797
+ ]
798
+ },
799
+ "execution_count": 24,
800
+ "metadata": {},
801
+ "output_type": "execute_result"
802
+ }
803
+ ],
804
+ "source": [
805
+ "df = Daru::DataFrame.new({\n",
806
+ " a: [1, 2, 4, -2, 5, 23, 0],\n",
807
+ " b: [3, 1, 3, -6, 2, 1, 0],\n",
808
+ " c: ['I', 'II', 'I', 'III', 'I', 'III', 'II']\n",
809
+ " })\n",
810
+ "df.to_category :c\n",
811
+ "df[:c].type"
812
+ ]
813
+ },
814
+ {
815
+ "cell_type": "code",
816
+ "execution_count": 25,
817
+ "metadata": {
818
+ "collapsed": false
819
+ },
820
+ "outputs": [
821
+ {
822
+ "data": {
823
+ "text/plain": [
824
+ "#<Daru::View::Plot:0x007fd05bac9af8 @data=#<Daru::DataFrame(7x3)>\n",
825
+ " a b c\n",
826
+ " 0 1 3 I\n",
827
+ " 1 2 1 II\n",
828
+ " 2 4 3 I\n",
829
+ " 3 -2 -6 III\n",
830
+ " 4 5 2 I\n",
831
+ " 5 23 1 III\n",
832
+ " 6 0 0 II, @options={:type=>:scatter, :x=>:a, :y=>:b, :categorized=>{:by=>:c, :method=>:color}}, @adapter=Daru::View::Adapter::NyaplotAdapter, @chart=#<Nyaplot::Plot:0x007fd05bac9a80 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05bac3720 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :color=>\"rgb(102,194,165)\", :tooltip_contents=>[\"I\", \"I\", \"I\"]}, :data=>\"65223cdc-8436-4095-bdc5-b7fa8f573b07\"}, @xrange=[1, 5], @yrange=[2, 3]>, #<Nyaplot::Diagram:0x007fd05b24a198 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :color=>\"rgb(252,141,98)\", :tooltip_contents=>[\"II\", \"II\"]}, :data=>\"b0f52746-cec0-4ef7-8a5b-10e1ea06e36f\"}, @xrange=[0, 2], @yrange=[0, 1]>, #<Nyaplot::Diagram:0x007fd05c24ba10 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :color=>\"rgb(141,160,203)\", :tooltip_contents=>[\"III\", \"III\"]}, :data=>\"e394ca43-e59f-4965-b25d-c42721aab2bf\"}, @xrange=[-2, 23], @yrange=[-6, 1]>], :options=>{:legend=>true}}>>"
833
+ ]
834
+ },
835
+ "execution_count": 25,
836
+ "metadata": {},
837
+ "output_type": "execute_result"
838
+ }
839
+ ],
840
+ "source": [
841
+ "scatter_1 = Daru::View::Plot.new(df, type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :color})"
842
+ ]
843
+ },
844
+ {
845
+ "cell_type": "code",
846
+ "execution_count": 26,
847
+ "metadata": {
848
+ "collapsed": false,
849
+ "scrolled": true
850
+ },
851
+ "outputs": [
852
+ {
853
+ "data": {
854
+ "text/html": [
855
+ "<div id='vis-fdaf3017-dba7-481a-8e9e-4b18ef0f7d74'></div>\n",
856
+ "<script>\n",
857
+ "(function(){\n",
858
+ " var render = function(){\n",
859
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"color\":\"rgb(102,194,165)\",\"tooltip_contents\":[\"I\",\"I\",\"I\"]},\"data\":\"65223cdc-8436-4095-bdc5-b7fa8f573b07\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"color\":\"rgb(252,141,98)\",\"tooltip_contents\":[\"II\",\"II\"]},\"data\":\"b0f52746-cec0-4ef7-8a5b-10e1ea06e36f\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"color\":\"rgb(141,160,203)\",\"tooltip_contents\":[\"III\",\"III\"]},\"data\":\"e394ca43-e59f-4965-b25d-c42721aab2bf\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[-2,23],\"yrange\":[-6,3]}}],\"data\":{\"65223cdc-8436-4095-bdc5-b7fa8f573b07\":[{\"a\":1,\"b\":3},{\"a\":4,\"b\":3},{\"a\":5,\"b\":2}],\"b0f52746-cec0-4ef7-8a5b-10e1ea06e36f\":[{\"a\":2,\"b\":1},{\"a\":0,\"b\":0}],\"e394ca43-e59f-4965-b25d-c42721aab2bf\":[{\"a\":-2,\"b\":-6},{\"a\":23,\"b\":1}]},\"extension\":[]}\n",
860
+ " var id_name = '#vis-fdaf3017-dba7-481a-8e9e-4b18ef0f7d74';\n",
861
+ " Nyaplot.core.parse(model, id_name);\n",
862
+ "\n",
863
+ " require(['downloadable'], function(downloadable){\n",
864
+ " var svg = d3.select(id_name).select(\"svg\");\n",
865
+ "\t if(!svg.empty())\n",
866
+ "\t svg.call(downloadable().filename('fig'));\n",
867
+ "\t});\n",
868
+ " };\n",
869
+ " if(window['Nyaplot']==undefined){\n",
870
+ " window.addEventListener('load_nyaplot', render, false);\n",
871
+ "\treturn;\n",
872
+ " } else {\n",
873
+ " render();\n",
874
+ " }\n",
875
+ "})();\n",
876
+ "</script>\n"
877
+ ],
878
+ "text/plain": [
879
+ "#<Nyaplot::Frame:0x007fd05b2291f0 @properties={:panes=>[#<Nyaplot::Plot:0x007fd05bac9a80 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05bac3720 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :color=>\"rgb(102,194,165)\", :tooltip_contents=>[\"I\", \"I\", \"I\"]}, :data=>\"65223cdc-8436-4095-bdc5-b7fa8f573b07\"}, @xrange=[1, 5], @yrange=[2, 3]>, #<Nyaplot::Diagram:0x007fd05b24a198 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :color=>\"rgb(252,141,98)\", :tooltip_contents=>[\"II\", \"II\"]}, :data=>\"b0f52746-cec0-4ef7-8a5b-10e1ea06e36f\"}, @xrange=[0, 2], @yrange=[0, 1]>, #<Nyaplot::Diagram:0x007fd05c24ba10 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :color=>\"rgb(141,160,203)\", :tooltip_contents=>[\"III\", \"III\"]}, :data=>\"e394ca43-e59f-4965-b25d-c42721aab2bf\"}, @xrange=[-2, 23], @yrange=[-6, 1]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[-2, 23], :yrange=>[-6, 3]}}>], :data=>{\"65223cdc-8436-4095-bdc5-b7fa8f573b07\"=>#<Nyaplot::DataFrame:0x007fd05bac3b80 @name=\"65223cdc-8436-4095-bdc5-b7fa8f573b07\", @rows=[{:a=>1, :b=>3}, {:a=>4, :b=>3}, {:a=>5, :b=>2}]>, \"b0f52746-cec0-4ef7-8a5b-10e1ea06e36f\"=>#<Nyaplot::DataFrame:0x007fd05b24a580 @name=\"b0f52746-cec0-4ef7-8a5b-10e1ea06e36f\", @rows=[{:a=>2, :b=>1}, {:a=>0, :b=>0}]>, \"e394ca43-e59f-4965-b25d-c42721aab2bf\"=>#<Nyaplot::DataFrame:0x007fd05c24bd80 @name=\"e394ca43-e59f-4965-b25d-c42721aab2bf\", @rows=[{:a=>-2, :b=>-6}, {:a=>23, :b=>1}]>}, :extension=>[]}>"
880
+ ]
881
+ },
882
+ "metadata": {},
883
+ "output_type": "display_data"
884
+ }
885
+ ],
886
+ "source": [
887
+ "scatter_1.show_in_iruby"
888
+ ]
889
+ },
890
+ {
891
+ "cell_type": "code",
892
+ "execution_count": 27,
893
+ "metadata": {
894
+ "collapsed": false
895
+ },
896
+ "outputs": [
897
+ {
898
+ "data": {
899
+ "text/html": [
900
+ "<div id='vis-d8fdb108-862a-4e6e-bb6a-6a17a6f07ad9'></div>\n",
901
+ "<script>\n",
902
+ "(function(){\n",
903
+ " var render = function(){\n",
904
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"color\":\"rgb(102,194,165)\",\"tooltip_contents\":[\"I\",\"I\",\"I\"]},\"data\":\"65223cdc-8436-4095-bdc5-b7fa8f573b07\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"color\":\"rgb(252,141,98)\",\"tooltip_contents\":[\"II\",\"II\"]},\"data\":\"b0f52746-cec0-4ef7-8a5b-10e1ea06e36f\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"color\":\"rgb(141,160,203)\",\"tooltip_contents\":[\"III\",\"III\"]},\"data\":\"e394ca43-e59f-4965-b25d-c42721aab2bf\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[-10,10],\"yrange\":[-10,10]}}],\"data\":{\"65223cdc-8436-4095-bdc5-b7fa8f573b07\":[{\"a\":1,\"b\":3},{\"a\":4,\"b\":3},{\"a\":5,\"b\":2}],\"b0f52746-cec0-4ef7-8a5b-10e1ea06e36f\":[{\"a\":2,\"b\":1},{\"a\":0,\"b\":0}],\"e394ca43-e59f-4965-b25d-c42721aab2bf\":[{\"a\":-2,\"b\":-6},{\"a\":23,\"b\":1}]},\"extension\":[]}\n",
905
+ " var id_name = '#vis-d8fdb108-862a-4e6e-bb6a-6a17a6f07ad9';\n",
906
+ " Nyaplot.core.parse(model, id_name);\n",
907
+ "\n",
908
+ " require(['downloadable'], function(downloadable){\n",
909
+ " var svg = d3.select(id_name).select(\"svg\");\n",
910
+ "\t if(!svg.empty())\n",
911
+ "\t svg.call(downloadable().filename('fig'));\n",
912
+ "\t});\n",
913
+ " };\n",
914
+ " if(window['Nyaplot']==undefined){\n",
915
+ " window.addEventListener('load_nyaplot', render, false);\n",
916
+ "\treturn;\n",
917
+ " } else {\n",
918
+ " render();\n",
919
+ " }\n",
920
+ "})();\n",
921
+ "</script>\n"
922
+ ],
923
+ "text/plain": [
924
+ "#<Nyaplot::Plot:0x007fd05bac9a80 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05bac3720 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :color=>\"rgb(102,194,165)\", :tooltip_contents=>[\"I\", \"I\", \"I\"]}, :data=>\"65223cdc-8436-4095-bdc5-b7fa8f573b07\"}, @xrange=[1, 5], @yrange=[2, 3]>, #<Nyaplot::Diagram:0x007fd05b24a198 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :color=>\"rgb(252,141,98)\", :tooltip_contents=>[\"II\", \"II\"]}, :data=>\"b0f52746-cec0-4ef7-8a5b-10e1ea06e36f\"}, @xrange=[0, 2], @yrange=[0, 1]>, #<Nyaplot::Diagram:0x007fd05c24ba10 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :color=>\"rgb(141,160,203)\", :tooltip_contents=>[\"III\", \"III\"]}, :data=>\"e394ca43-e59f-4965-b25d-c42721aab2bf\"}, @xrange=[-2, 23], @yrange=[-6, 1]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[-10, 10], :yrange=>[-10, 10]}}>"
925
+ ]
926
+ },
927
+ "execution_count": 27,
928
+ "metadata": {},
929
+ "output_type": "execute_result"
930
+ }
931
+ ],
932
+ "source": [
933
+ "scatter_1.chart.xrange [-10, 10]\n",
934
+ "scatter_1.chart.yrange [-10, 10]"
935
+ ]
936
+ },
937
+ {
938
+ "cell_type": "code",
939
+ "execution_count": 28,
940
+ "metadata": {
941
+ "collapsed": false
942
+ },
943
+ "outputs": [
944
+ {
945
+ "data": {
946
+ "text/html": [
947
+ "<div id='vis-8a4277f1-830d-46bd-aa71-dd55b4385772'></div>\n",
948
+ "<script>\n",
949
+ "(function(){\n",
950
+ " var render = function(){\n",
951
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"shape\":\"circle\",\"tooltip_contents\":[\"I\",\"I\",\"I\"]},\"data\":\"827961c8-07b6-4e43-92e4-ad118cacac4d\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"shape\":\"triangle-up\",\"tooltip_contents\":[\"II\",\"II\"]},\"data\":\"f05f2c4a-627e-44df-8b35-985718e0dde8\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"shape\":\"diamond\",\"tooltip_contents\":[\"III\",\"III\"]},\"data\":\"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[-2,23],\"yrange\":[-6,3]}}],\"data\":{\"827961c8-07b6-4e43-92e4-ad118cacac4d\":[{\"a\":1,\"b\":3},{\"a\":4,\"b\":3},{\"a\":5,\"b\":2}],\"f05f2c4a-627e-44df-8b35-985718e0dde8\":[{\"a\":2,\"b\":1},{\"a\":0,\"b\":0}],\"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\":[{\"a\":-2,\"b\":-6},{\"a\":23,\"b\":1}]},\"extension\":[]}\n",
952
+ " var id_name = '#vis-8a4277f1-830d-46bd-aa71-dd55b4385772';\n",
953
+ " Nyaplot.core.parse(model, id_name);\n",
954
+ "\n",
955
+ " require(['downloadable'], function(downloadable){\n",
956
+ " var svg = d3.select(id_name).select(\"svg\");\n",
957
+ "\t if(!svg.empty())\n",
958
+ "\t svg.call(downloadable().filename('fig'));\n",
959
+ "\t});\n",
960
+ " };\n",
961
+ " if(window['Nyaplot']==undefined){\n",
962
+ " window.addEventListener('load_nyaplot', render, false);\n",
963
+ "\treturn;\n",
964
+ " } else {\n",
965
+ " render();\n",
966
+ " }\n",
967
+ "})();\n",
968
+ "</script>\n"
969
+ ],
970
+ "text/plain": [
971
+ "#<Nyaplot::Frame:0x007fd05c1d0ef0 @properties={:panes=>[#<Nyaplot::Plot:0x007fd05c1db378 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05c9a8bc8 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :shape=>\"circle\", :tooltip_contents=>[\"I\", \"I\", \"I\"]}, :data=>\"827961c8-07b6-4e43-92e4-ad118cacac4d\"}, @xrange=[1, 5], @yrange=[2, 3]>, #<Nyaplot::Diagram:0x007fd05baabfa8 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :shape=>\"triangle-up\", :tooltip_contents=>[\"II\", \"II\"]}, :data=>\"f05f2c4a-627e-44df-8b35-985718e0dde8\"}, @xrange=[0, 2], @yrange=[0, 1]>, #<Nyaplot::Diagram:0x007fd05c1d2098 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :shape=>\"diamond\", :tooltip_contents=>[\"III\", \"III\"]}, :data=>\"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\"}, @xrange=[-2, 23], @yrange=[-6, 1]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[-2, 23], :yrange=>[-6, 3]}}>], :data=>{\"827961c8-07b6-4e43-92e4-ad118cacac4d\"=>#<Nyaplot::DataFrame:0x007fd05c9a8fd8 @name=\"827961c8-07b6-4e43-92e4-ad118cacac4d\", @rows=[{:a=>1, :b=>3}, {:a=>4, :b=>3}, {:a=>5, :b=>2}]>, \"f05f2c4a-627e-44df-8b35-985718e0dde8\"=>#<Nyaplot::DataFrame:0x007fd05b208270 @name=\"f05f2c4a-627e-44df-8b35-985718e0dde8\", @rows=[{:a=>2, :b=>1}, {:a=>0, :b=>0}]>, \"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\"=>#<Nyaplot::DataFrame:0x007fd05c1d2408 @name=\"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\", @rows=[{:a=>-2, :b=>-6}, {:a=>23, :b=>1}]>}, :extension=>[]}>"
972
+ ]
973
+ },
974
+ "metadata": {},
975
+ "output_type": "display_data"
976
+ }
977
+ ],
978
+ "source": [
979
+ "scatter_2 = Daru::View::Plot.new(df, type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :shape})\n",
980
+ "scatter_2.show_in_iruby"
981
+ ]
982
+ },
983
+ {
984
+ "cell_type": "code",
985
+ "execution_count": 29,
986
+ "metadata": {
987
+ "collapsed": false
988
+ },
989
+ "outputs": [
990
+ {
991
+ "data": {
992
+ "text/html": [
993
+ "<div id='vis-c959743a-7a5f-472a-9399-2eb8bb4b0978'></div>\n",
994
+ "<script>\n",
995
+ "(function(){\n",
996
+ " var render = function(){\n",
997
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"shape\":\"circle\",\"tooltip_contents\":[\"I\",\"I\",\"I\"]},\"data\":\"827961c8-07b6-4e43-92e4-ad118cacac4d\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"shape\":\"triangle-up\",\"tooltip_contents\":[\"II\",\"II\"]},\"data\":\"f05f2c4a-627e-44df-8b35-985718e0dde8\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"shape\":\"diamond\",\"tooltip_contents\":[\"III\",\"III\"]},\"data\":\"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[-10,10],\"yrange\":[-10,10]}}],\"data\":{\"827961c8-07b6-4e43-92e4-ad118cacac4d\":[{\"a\":1,\"b\":3},{\"a\":4,\"b\":3},{\"a\":5,\"b\":2}],\"f05f2c4a-627e-44df-8b35-985718e0dde8\":[{\"a\":2,\"b\":1},{\"a\":0,\"b\":0}],\"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\":[{\"a\":-2,\"b\":-6},{\"a\":23,\"b\":1}]},\"extension\":[]}\n",
998
+ " var id_name = '#vis-c959743a-7a5f-472a-9399-2eb8bb4b0978';\n",
999
+ " Nyaplot.core.parse(model, id_name);\n",
1000
+ "\n",
1001
+ " require(['downloadable'], function(downloadable){\n",
1002
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1003
+ "\t if(!svg.empty())\n",
1004
+ "\t svg.call(downloadable().filename('fig'));\n",
1005
+ "\t});\n",
1006
+ " };\n",
1007
+ " if(window['Nyaplot']==undefined){\n",
1008
+ " window.addEventListener('load_nyaplot', render, false);\n",
1009
+ "\treturn;\n",
1010
+ " } else {\n",
1011
+ " render();\n",
1012
+ " }\n",
1013
+ "})();\n",
1014
+ "</script>\n"
1015
+ ],
1016
+ "text/plain": [
1017
+ "#<Nyaplot::Plot:0x007fd05c1db378 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05c9a8bc8 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :shape=>\"circle\", :tooltip_contents=>[\"I\", \"I\", \"I\"]}, :data=>\"827961c8-07b6-4e43-92e4-ad118cacac4d\"}, @xrange=[1, 5], @yrange=[2, 3]>, #<Nyaplot::Diagram:0x007fd05baabfa8 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :shape=>\"triangle-up\", :tooltip_contents=>[\"II\", \"II\"]}, :data=>\"f05f2c4a-627e-44df-8b35-985718e0dde8\"}, @xrange=[0, 2], @yrange=[0, 1]>, #<Nyaplot::Diagram:0x007fd05c1d2098 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :shape=>\"diamond\", :tooltip_contents=>[\"III\", \"III\"]}, :data=>\"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\"}, @xrange=[-2, 23], @yrange=[-6, 1]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[-10, 10], :yrange=>[-10, 10]}}>"
1018
+ ]
1019
+ },
1020
+ "execution_count": 29,
1021
+ "metadata": {},
1022
+ "output_type": "execute_result"
1023
+ }
1024
+ ],
1025
+ "source": [
1026
+ "scatter_2.chart.xrange [-10, 10]\n",
1027
+ "scatter_2.chart.yrange [-10, 10]"
1028
+ ]
1029
+ },
1030
+ {
1031
+ "cell_type": "code",
1032
+ "execution_count": 30,
1033
+ "metadata": {
1034
+ "collapsed": false
1035
+ },
1036
+ "outputs": [
1037
+ {
1038
+ "data": {
1039
+ "text/html": [
1040
+ "<div id='vis-a4e5b8fd-b9c6-4808-9297-8e1d0a08f17e'></div>\n",
1041
+ "<script>\n",
1042
+ "(function(){\n",
1043
+ " var render = function(){\n",
1044
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"color\":\"red\",\"tooltip_contents\":[\"I\",\"I\",\"I\"]},\"data\":\"5b8a7ee4-3210-492b-886e-d641848b8778\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"color\":\"blue\",\"tooltip_contents\":[\"II\",\"II\"]},\"data\":\"37a84466-b577-46f8-a015-86e200739f0c\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"color\":\"green\",\"tooltip_contents\":[\"III\",\"III\"]},\"data\":\"188bbf12-a236-43d8-852c-e66cddbead9e\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[-2,23],\"yrange\":[-6,3]}}],\"data\":{\"5b8a7ee4-3210-492b-886e-d641848b8778\":[{\"a\":1,\"b\":3},{\"a\":4,\"b\":3},{\"a\":5,\"b\":2}],\"37a84466-b577-46f8-a015-86e200739f0c\":[{\"a\":2,\"b\":1},{\"a\":0,\"b\":0}],\"188bbf12-a236-43d8-852c-e66cddbead9e\":[{\"a\":-2,\"b\":-6},{\"a\":23,\"b\":1}]},\"extension\":[]}\n",
1045
+ " var id_name = '#vis-a4e5b8fd-b9c6-4808-9297-8e1d0a08f17e';\n",
1046
+ " Nyaplot.core.parse(model, id_name);\n",
1047
+ "\n",
1048
+ " require(['downloadable'], function(downloadable){\n",
1049
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1050
+ "\t if(!svg.empty())\n",
1051
+ "\t svg.call(downloadable().filename('fig'));\n",
1052
+ "\t});\n",
1053
+ " };\n",
1054
+ " if(window['Nyaplot']==undefined){\n",
1055
+ " window.addEventListener('load_nyaplot', render, false);\n",
1056
+ "\treturn;\n",
1057
+ " } else {\n",
1058
+ " render();\n",
1059
+ " }\n",
1060
+ "})();\n",
1061
+ "</script>\n"
1062
+ ],
1063
+ "text/plain": [
1064
+ "#<Nyaplot::Frame:0x007fd05c12b5e0 @properties={:panes=>[#<Nyaplot::Plot:0x007fd05c16a1c8 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05c158040 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :color=>:red, :tooltip_contents=>[\"I\", \"I\", \"I\"]}, :data=>\"5b8a7ee4-3210-492b-886e-d641848b8778\"}, @xrange=[1, 5], @yrange=[2, 3]>, #<Nyaplot::Diagram:0x007fd05c13b210 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :color=>:blue, :tooltip_contents=>[\"II\", \"II\"]}, :data=>\"37a84466-b577-46f8-a015-86e200739f0c\"}, @xrange=[0, 2], @yrange=[0, 1]>, #<Nyaplot::Diagram:0x007fd05c1311e8 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :color=>:green, :tooltip_contents=>[\"III\", \"III\"]}, :data=>\"188bbf12-a236-43d8-852c-e66cddbead9e\"}, @xrange=[-2, 23], @yrange=[-6, 1]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[-2, 23], :yrange=>[-6, 3]}}>], :data=>{\"5b8a7ee4-3210-492b-886e-d641848b8778\"=>#<Nyaplot::DataFrame:0x007fd05c158838 @name=\"5b8a7ee4-3210-492b-886e-d641848b8778\", @rows=[{:a=>1, :b=>3}, {:a=>4, :b=>3}, {:a=>5, :b=>2}]>, \"37a84466-b577-46f8-a015-86e200739f0c\"=>#<Nyaplot::DataFrame:0x007fd05c13b760 @name=\"37a84466-b577-46f8-a015-86e200739f0c\", @rows=[{:a=>2, :b=>1}, {:a=>0, :b=>0}]>, \"188bbf12-a236-43d8-852c-e66cddbead9e\"=>#<Nyaplot::DataFrame:0x007fd05c1315d0 @name=\"188bbf12-a236-43d8-852c-e66cddbead9e\", @rows=[{:a=>-2, :b=>-6}, {:a=>23, :b=>1}]>}, :extension=>[]}>"
1065
+ ]
1066
+ },
1067
+ "metadata": {},
1068
+ "output_type": "display_data"
1069
+ },
1070
+ {
1071
+ "data": {
1072
+ "text/html": [
1073
+ "<div id='vis-7eefae9c-5917-4cd4-ba89-77827220a672'></div>\n",
1074
+ "<script>\n",
1075
+ "(function(){\n",
1076
+ " var render = function(){\n",
1077
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"shape\":\"circle\",\"tooltip_contents\":[\"I\",\"I\",\"I\"]},\"data\":\"827961c8-07b6-4e43-92e4-ad118cacac4d\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"shape\":\"triangle-up\",\"tooltip_contents\":[\"II\",\"II\"]},\"data\":\"f05f2c4a-627e-44df-8b35-985718e0dde8\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"shape\":\"diamond\",\"tooltip_contents\":[\"III\",\"III\"]},\"data\":\"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[-10,10],\"yrange\":[-10,10]}}],\"data\":{\"827961c8-07b6-4e43-92e4-ad118cacac4d\":[{\"a\":1,\"b\":3},{\"a\":4,\"b\":3},{\"a\":5,\"b\":2}],\"f05f2c4a-627e-44df-8b35-985718e0dde8\":[{\"a\":2,\"b\":1},{\"a\":0,\"b\":0}],\"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\":[{\"a\":-2,\"b\":-6},{\"a\":23,\"b\":1}]},\"extension\":[]}\n",
1078
+ " var id_name = '#vis-7eefae9c-5917-4cd4-ba89-77827220a672';\n",
1079
+ " Nyaplot.core.parse(model, id_name);\n",
1080
+ "\n",
1081
+ " require(['downloadable'], function(downloadable){\n",
1082
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1083
+ "\t if(!svg.empty())\n",
1084
+ "\t svg.call(downloadable().filename('fig'));\n",
1085
+ "\t});\n",
1086
+ " };\n",
1087
+ " if(window['Nyaplot']==undefined){\n",
1088
+ " window.addEventListener('load_nyaplot', render, false);\n",
1089
+ "\treturn;\n",
1090
+ " } else {\n",
1091
+ " render();\n",
1092
+ " }\n",
1093
+ "})();\n",
1094
+ "</script>\n"
1095
+ ],
1096
+ "text/plain": [
1097
+ "#<Nyaplot::Plot:0x007fd05c1db378 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05c9a8bc8 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :shape=>\"circle\", :tooltip_contents=>[\"I\", \"I\", \"I\"]}, :data=>\"827961c8-07b6-4e43-92e4-ad118cacac4d\"}, @xrange=[1, 5], @yrange=[2, 3]>, #<Nyaplot::Diagram:0x007fd05baabfa8 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :shape=>\"triangle-up\", :tooltip_contents=>[\"II\", \"II\"]}, :data=>\"f05f2c4a-627e-44df-8b35-985718e0dde8\"}, @xrange=[0, 2], @yrange=[0, 1]>, #<Nyaplot::Diagram:0x007fd05c1d2098 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :shape=>\"diamond\", :tooltip_contents=>[\"III\", \"III\"]}, :data=>\"3f90c3cf-18f4-4789-9ddd-c2dbbac066c9\"}, @xrange=[-2, 23], @yrange=[-6, 1]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[-10, 10], :yrange=>[-10, 10]}}>"
1098
+ ]
1099
+ },
1100
+ "execution_count": 30,
1101
+ "metadata": {},
1102
+ "output_type": "execute_result"
1103
+ }
1104
+ ],
1105
+ "source": [
1106
+ "scatter_3 = Daru::View::Plot.new(df, type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :color, color: [:red, :blue, :green]})\n",
1107
+ "scatter_3.show_in_iruby\n",
1108
+ "scatter_2.chart.xrange [-10, 10]\n",
1109
+ "scatter_2.chart.yrange [-10, 10]"
1110
+ ]
1111
+ },
1112
+ {
1113
+ "cell_type": "code",
1114
+ "execution_count": 31,
1115
+ "metadata": {
1116
+ "collapsed": false
1117
+ },
1118
+ "outputs": [
1119
+ {
1120
+ "data": {
1121
+ "text/html": [
1122
+ "<div id='vis-8ae12741-1caa-44e4-87c3-8adf87119c10'></div>\n",
1123
+ "<script>\n",
1124
+ "(function(){\n",
1125
+ " var render = function(){\n",
1126
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"size\":300,\"tooltip_contents\":[\"I\",\"I\",\"I\"]},\"data\":\"b7fadd95-2003-4643-90e5-336cbaff1af4\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"size\":600,\"tooltip_contents\":[\"II\",\"II\"]},\"data\":\"38bb6200-a8ed-4a87-9ca1-ec7edabeab48\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"size\":900,\"tooltip_contents\":[\"III\",\"III\"]},\"data\":\"25caef61-eaa1-4c73-a8b7-031dbb8b1b9f\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[-2,23],\"yrange\":[-6,3]}}],\"data\":{\"b7fadd95-2003-4643-90e5-336cbaff1af4\":[{\"a\":1,\"b\":3},{\"a\":4,\"b\":3},{\"a\":5,\"b\":2}],\"38bb6200-a8ed-4a87-9ca1-ec7edabeab48\":[{\"a\":2,\"b\":1},{\"a\":0,\"b\":0}],\"25caef61-eaa1-4c73-a8b7-031dbb8b1b9f\":[{\"a\":-2,\"b\":-6},{\"a\":23,\"b\":1}]},\"extension\":[]}\n",
1127
+ " var id_name = '#vis-8ae12741-1caa-44e4-87c3-8adf87119c10';\n",
1128
+ " Nyaplot.core.parse(model, id_name);\n",
1129
+ "\n",
1130
+ " require(['downloadable'], function(downloadable){\n",
1131
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1132
+ "\t if(!svg.empty())\n",
1133
+ "\t svg.call(downloadable().filename('fig'));\n",
1134
+ "\t});\n",
1135
+ " };\n",
1136
+ " if(window['Nyaplot']==undefined){\n",
1137
+ " window.addEventListener('load_nyaplot', render, false);\n",
1138
+ "\treturn;\n",
1139
+ " } else {\n",
1140
+ " render();\n",
1141
+ " }\n",
1142
+ "})();\n",
1143
+ "</script>\n"
1144
+ ],
1145
+ "text/plain": [
1146
+ "#<Nyaplot::Frame:0x007fd05c9743a0 @properties={:panes=>[#<Nyaplot::Plot:0x007fd05b191530 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05b181a40 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :size=>300, :tooltip_contents=>[\"I\", \"I\", \"I\"]}, :data=>\"b7fadd95-2003-4643-90e5-336cbaff1af4\"}, @xrange=[1, 5], @yrange=[2, 3]>, #<Nyaplot::Diagram:0x007fd05b172040 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :size=>600, :tooltip_contents=>[\"II\", \"II\"]}, :data=>\"38bb6200-a8ed-4a87-9ca1-ec7edabeab48\"}, @xrange=[0, 2], @yrange=[0, 1]>, #<Nyaplot::Diagram:0x007fd05c975b38 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :size=>900, :tooltip_contents=>[\"III\", \"III\"]}, :data=>\"25caef61-eaa1-4c73-a8b7-031dbb8b1b9f\"}, @xrange=[-2, 23], @yrange=[-6, 1]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[-2, 23], :yrange=>[-6, 3]}}>], :data=>{\"b7fadd95-2003-4643-90e5-336cbaff1af4\"=>#<Nyaplot::DataFrame:0x007fd05b182058 @name=\"b7fadd95-2003-4643-90e5-336cbaff1af4\", @rows=[{:a=>1, :b=>3}, {:a=>4, :b=>3}, {:a=>5, :b=>2}]>, \"38bb6200-a8ed-4a87-9ca1-ec7edabeab48\"=>#<Nyaplot::DataFrame:0x007fd05b172478 @name=\"38bb6200-a8ed-4a87-9ca1-ec7edabeab48\", @rows=[{:a=>2, :b=>1}, {:a=>0, :b=>0}]>, \"25caef61-eaa1-4c73-a8b7-031dbb8b1b9f\"=>#<Nyaplot::DataFrame:0x007fd05c976948 @name=\"25caef61-eaa1-4c73-a8b7-031dbb8b1b9f\", @rows=[{:a=>-2, :b=>-6}, {:a=>23, :b=>1}]>}, :extension=>[]}>"
1147
+ ]
1148
+ },
1149
+ "metadata": {},
1150
+ "output_type": "display_data"
1151
+ },
1152
+ {
1153
+ "data": {
1154
+ "text/html": [
1155
+ "<div id='vis-5f9addad-0d19-47e0-95e3-929b47b873f0'></div>\n",
1156
+ "<script>\n",
1157
+ "(function(){\n",
1158
+ " var render = function(){\n",
1159
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"size\":300,\"tooltip_contents\":[\"I\",\"I\",\"I\"]},\"data\":\"b7fadd95-2003-4643-90e5-336cbaff1af4\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"size\":600,\"tooltip_contents\":[\"II\",\"II\"]},\"data\":\"38bb6200-a8ed-4a87-9ca1-ec7edabeab48\"},{\"type\":\"scatter\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"size\":900,\"tooltip_contents\":[\"III\",\"III\"]},\"data\":\"25caef61-eaa1-4c73-a8b7-031dbb8b1b9f\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[-10,10],\"yrange\":[-10,10]}}],\"data\":{\"b7fadd95-2003-4643-90e5-336cbaff1af4\":[{\"a\":1,\"b\":3},{\"a\":4,\"b\":3},{\"a\":5,\"b\":2}],\"38bb6200-a8ed-4a87-9ca1-ec7edabeab48\":[{\"a\":2,\"b\":1},{\"a\":0,\"b\":0}],\"25caef61-eaa1-4c73-a8b7-031dbb8b1b9f\":[{\"a\":-2,\"b\":-6},{\"a\":23,\"b\":1}]},\"extension\":[]}\n",
1160
+ " var id_name = '#vis-5f9addad-0d19-47e0-95e3-929b47b873f0';\n",
1161
+ " Nyaplot.core.parse(model, id_name);\n",
1162
+ "\n",
1163
+ " require(['downloadable'], function(downloadable){\n",
1164
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1165
+ "\t if(!svg.empty())\n",
1166
+ "\t svg.call(downloadable().filename('fig'));\n",
1167
+ "\t});\n",
1168
+ " };\n",
1169
+ " if(window['Nyaplot']==undefined){\n",
1170
+ " window.addEventListener('load_nyaplot', render, false);\n",
1171
+ "\treturn;\n",
1172
+ " } else {\n",
1173
+ " render();\n",
1174
+ " }\n",
1175
+ "})();\n",
1176
+ "</script>\n"
1177
+ ],
1178
+ "text/plain": [
1179
+ "#<Nyaplot::Plot:0x007fd05b191530 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05b181a40 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :size=>300, :tooltip_contents=>[\"I\", \"I\", \"I\"]}, :data=>\"b7fadd95-2003-4643-90e5-336cbaff1af4\"}, @xrange=[1, 5], @yrange=[2, 3]>, #<Nyaplot::Diagram:0x007fd05b172040 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :size=>600, :tooltip_contents=>[\"II\", \"II\"]}, :data=>\"38bb6200-a8ed-4a87-9ca1-ec7edabeab48\"}, @xrange=[0, 2], @yrange=[0, 1]>, #<Nyaplot::Diagram:0x007fd05c975b38 @properties={:type=>:scatter, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :size=>900, :tooltip_contents=>[\"III\", \"III\"]}, :data=>\"25caef61-eaa1-4c73-a8b7-031dbb8b1b9f\"}, @xrange=[-2, 23], @yrange=[-6, 1]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[-10, 10], :yrange=>[-10, 10]}}>"
1180
+ ]
1181
+ },
1182
+ "execution_count": 31,
1183
+ "metadata": {},
1184
+ "output_type": "execute_result"
1185
+ }
1186
+ ],
1187
+ "source": [
1188
+ "scatter_4 = Daru::View::Plot.new(df, type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :size, size: [300, 600, 900]})\n",
1189
+ "scatter_4.show_in_iruby\n",
1190
+ "scatter_4.chart.xrange [-10, 10]\n",
1191
+ "scatter_4.chart.yrange [-10, 10]"
1192
+ ]
1193
+ },
1194
+ {
1195
+ "cell_type": "markdown",
1196
+ "metadata": {},
1197
+ "source": [
1198
+ "### Line plot categorized by categorical variable\n",
1199
+ "It works similar to Scatter plot above and all options are same except that there's no categorization by size but instead there is categorization by stroke_width in line plots."
1200
+ ]
1201
+ },
1202
+ {
1203
+ "cell_type": "code",
1204
+ "execution_count": 32,
1205
+ "metadata": {
1206
+ "collapsed": false
1207
+ },
1208
+ "outputs": [
1209
+ {
1210
+ "data": {
1211
+ "text/plain": [
1212
+ ":category"
1213
+ ]
1214
+ },
1215
+ "execution_count": 32,
1216
+ "metadata": {},
1217
+ "output_type": "execute_result"
1218
+ }
1219
+ ],
1220
+ "source": [
1221
+ "df = Daru::DataFrame.new({\n",
1222
+ " a: [1, 2, 3, 4, 5, 6, 7, 8, 9],\n",
1223
+ " b: [2, 4, 6, 1, 3, 5, 6, 4, 3],\n",
1224
+ " c: ['I']*3 + ['II']*3 + ['III']*3\n",
1225
+ " })\n",
1226
+ "df.to_category :c\n",
1227
+ "df[:c].type"
1228
+ ]
1229
+ },
1230
+ {
1231
+ "cell_type": "code",
1232
+ "execution_count": 33,
1233
+ "metadata": {
1234
+ "collapsed": false
1235
+ },
1236
+ "outputs": [
1237
+ {
1238
+ "data": {
1239
+ "text/html": [
1240
+ "<div id='vis-ee6e186c-7412-4aa0-a06f-a5c385f4e2ba'></div>\n",
1241
+ "<script>\n",
1242
+ "(function(){\n",
1243
+ " var render = function(){\n",
1244
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"line\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"color\":\"rgb(251,180,174)\"},\"data\":\"a49ceebd-9f3b-4d47-a770-e43135c06253\"},{\"type\":\"line\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"color\":\"rgb(179,205,227)\"},\"data\":\"6dc7ffb8-5005-486e-bd44-2346eee11c00\"},{\"type\":\"line\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"color\":\"rgb(204,235,197)\"},\"data\":\"b53af3ce-b6f5-4713-87f4-c7bd17d83233\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[1,9],\"yrange\":[1,6]}}],\"data\":{\"a49ceebd-9f3b-4d47-a770-e43135c06253\":[{\"a\":1,\"b\":2},{\"a\":2,\"b\":4},{\"a\":3,\"b\":6}],\"6dc7ffb8-5005-486e-bd44-2346eee11c00\":[{\"a\":4,\"b\":1},{\"a\":5,\"b\":3},{\"a\":6,\"b\":5}],\"b53af3ce-b6f5-4713-87f4-c7bd17d83233\":[{\"a\":7,\"b\":6},{\"a\":8,\"b\":4},{\"a\":9,\"b\":3}]},\"extension\":[]}\n",
1245
+ " var id_name = '#vis-ee6e186c-7412-4aa0-a06f-a5c385f4e2ba';\n",
1246
+ " Nyaplot.core.parse(model, id_name);\n",
1247
+ "\n",
1248
+ " require(['downloadable'], function(downloadable){\n",
1249
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1250
+ "\t if(!svg.empty())\n",
1251
+ "\t svg.call(downloadable().filename('fig'));\n",
1252
+ "\t});\n",
1253
+ " };\n",
1254
+ " if(window['Nyaplot']==undefined){\n",
1255
+ " window.addEventListener('load_nyaplot', render, false);\n",
1256
+ "\treturn;\n",
1257
+ " } else {\n",
1258
+ " render();\n",
1259
+ " }\n",
1260
+ "})();\n",
1261
+ "</script>\n"
1262
+ ],
1263
+ "text/plain": [
1264
+ "#<Nyaplot::Frame:0x007fd05c8f4ba0 @properties={:panes=>[#<Nyaplot::Plot:0x007fd05b06bac0 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05b049ad8 @properties={:type=>:line, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :color=>\"rgb(251,180,174)\"}, :data=>\"a49ceebd-9f3b-4d47-a770-e43135c06253\"}, @xrange=[1, 3], @yrange=[2, 6]>, #<Nyaplot::Diagram:0x007fd05c936ff0 @properties={:type=>:line, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :color=>\"rgb(179,205,227)\"}, :data=>\"6dc7ffb8-5005-486e-bd44-2346eee11c00\"}, @xrange=[4, 6], @yrange=[1, 5]>, #<Nyaplot::Diagram:0x007fd05c8fe150 @properties={:type=>:line, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :color=>\"rgb(204,235,197)\"}, :data=>\"b53af3ce-b6f5-4713-87f4-c7bd17d83233\"}, @xrange=[7, 9], @yrange=[3, 6]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[1, 9], :yrange=>[1, 6]}}>], :data=>{\"a49ceebd-9f3b-4d47-a770-e43135c06253\"=>#<Nyaplot::DataFrame:0x007fd05b04aed8 @name=\"a49ceebd-9f3b-4d47-a770-e43135c06253\", @rows=[{:a=>1, :b=>2}, {:a=>2, :b=>4}, {:a=>3, :b=>6}]>, \"6dc7ffb8-5005-486e-bd44-2346eee11c00\"=>#<Nyaplot::DataFrame:0x007fd05c937ab8 @name=\"6dc7ffb8-5005-486e-bd44-2346eee11c00\", @rows=[{:a=>4, :b=>1}, {:a=>5, :b=>3}, {:a=>6, :b=>5}]>, \"b53af3ce-b6f5-4713-87f4-c7bd17d83233\"=>#<Nyaplot::DataFrame:0x007fd05c8ffde8 @name=\"b53af3ce-b6f5-4713-87f4-c7bd17d83233\", @rows=[{:a=>7, :b=>6}, {:a=>8, :b=>4}, {:a=>9, :b=>3}]>}, :extension=>[]}>"
1265
+ ]
1266
+ },
1267
+ "metadata": {},
1268
+ "output_type": "display_data"
1269
+ }
1270
+ ],
1271
+ "source": [
1272
+ "line_1 = Daru::View::Plot.new(df, type: :line, x: :a, y: :b, categorized: {by: :c, method: :color})\n",
1273
+ "line_1.show_in_iruby"
1274
+ ]
1275
+ },
1276
+ {
1277
+ "cell_type": "code",
1278
+ "execution_count": 34,
1279
+ "metadata": {
1280
+ "collapsed": false
1281
+ },
1282
+ "outputs": [
1283
+ {
1284
+ "data": {
1285
+ "text/html": [
1286
+ "<div id='vis-bfe48f50-2780-41f1-8d72-609ab167eb26'></div>\n",
1287
+ "<script>\n",
1288
+ "(function(){\n",
1289
+ " var render = function(){\n",
1290
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"line\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"stroke_width\":2},\"data\":\"178c614d-0e82-4b7a-9dc2-a081206bc196\"},{\"type\":\"line\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"stroke_width\":4},\"data\":\"ff20f4a8-f3c9-4103-9fa6-3ffc7204d9e2\"},{\"type\":\"line\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"stroke_width\":6},\"data\":\"5f2efc6f-a1a2-40a5-84dc-88b900e1cded\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[1,9],\"yrange\":[1,6]}}],\"data\":{\"178c614d-0e82-4b7a-9dc2-a081206bc196\":[{\"a\":1,\"b\":2},{\"a\":2,\"b\":4},{\"a\":3,\"b\":6}],\"ff20f4a8-f3c9-4103-9fa6-3ffc7204d9e2\":[{\"a\":4,\"b\":1},{\"a\":5,\"b\":3},{\"a\":6,\"b\":5}],\"5f2efc6f-a1a2-40a5-84dc-88b900e1cded\":[{\"a\":7,\"b\":6},{\"a\":8,\"b\":4},{\"a\":9,\"b\":3}]},\"extension\":[]}\n",
1291
+ " var id_name = '#vis-bfe48f50-2780-41f1-8d72-609ab167eb26';\n",
1292
+ " Nyaplot.core.parse(model, id_name);\n",
1293
+ "\n",
1294
+ " require(['downloadable'], function(downloadable){\n",
1295
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1296
+ "\t if(!svg.empty())\n",
1297
+ "\t svg.call(downloadable().filename('fig'));\n",
1298
+ "\t});\n",
1299
+ " };\n",
1300
+ " if(window['Nyaplot']==undefined){\n",
1301
+ " window.addEventListener('load_nyaplot', render, false);\n",
1302
+ "\treturn;\n",
1303
+ " } else {\n",
1304
+ " render();\n",
1305
+ " }\n",
1306
+ "})();\n",
1307
+ "</script>\n"
1308
+ ],
1309
+ "text/plain": [
1310
+ "#<Nyaplot::Frame:0x007fd05b8bd160 @properties={:panes=>[#<Nyaplot::Plot:0x007fd05c054270 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05c01c730 @properties={:type=>:line, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :stroke_width=>2}, :data=>\"178c614d-0e82-4b7a-9dc2-a081206bc196\"}, @xrange=[1, 3], @yrange=[2, 6]>, #<Nyaplot::Diagram:0x007fd05c84eb60 @properties={:type=>:line, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :stroke_width=>4}, :data=>\"ff20f4a8-f3c9-4103-9fa6-3ffc7204d9e2\"}, @xrange=[4, 6], @yrange=[1, 5]>, #<Nyaplot::Diagram:0x007fd05b0180f0 @properties={:type=>:line, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :stroke_width=>6}, :data=>\"5f2efc6f-a1a2-40a5-84dc-88b900e1cded\"}, @xrange=[7, 9], @yrange=[3, 6]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[1, 9], :yrange=>[1, 6]}}>], :data=>{\"178c614d-0e82-4b7a-9dc2-a081206bc196\"=>#<Nyaplot::DataFrame:0x007fd05c02cb80 @name=\"178c614d-0e82-4b7a-9dc2-a081206bc196\", @rows=[{:a=>1, :b=>2}, {:a=>2, :b=>4}, {:a=>3, :b=>6}]>, \"ff20f4a8-f3c9-4103-9fa6-3ffc7204d9e2\"=>#<Nyaplot::DataFrame:0x007fd05c85c378 @name=\"ff20f4a8-f3c9-4103-9fa6-3ffc7204d9e2\", @rows=[{:a=>4, :b=>1}, {:a=>5, :b=>3}, {:a=>6, :b=>5}]>, \"5f2efc6f-a1a2-40a5-84dc-88b900e1cded\"=>#<Nyaplot::DataFrame:0x007fd05b018fa0 @name=\"5f2efc6f-a1a2-40a5-84dc-88b900e1cded\", @rows=[{:a=>7, :b=>6}, {:a=>8, :b=>4}, {:a=>9, :b=>3}]>}, :extension=>[]}>"
1311
+ ]
1312
+ },
1313
+ "metadata": {},
1314
+ "output_type": "display_data"
1315
+ },
1316
+ {
1317
+ "data": {
1318
+ "text/html": [
1319
+ "<div id='vis-12367786-a326-4f34-866f-84391cf29311'></div>\n",
1320
+ "<script>\n",
1321
+ "(function(){\n",
1322
+ " var render = function(){\n",
1323
+ " var model = {\"panes\":[{\"diagrams\":[{\"type\":\"line\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"I\",\"stroke_width\":2},\"data\":\"178c614d-0e82-4b7a-9dc2-a081206bc196\"},{\"type\":\"line\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"II\",\"stroke_width\":4},\"data\":\"ff20f4a8-f3c9-4103-9fa6-3ffc7204d9e2\"},{\"type\":\"line\",\"options\":{\"x\":\"a\",\"y\":\"b\",\"title\":\"III\",\"stroke_width\":6},\"data\":\"5f2efc6f-a1a2-40a5-84dc-88b900e1cded\"}],\"options\":{\"legend\":true,\"zoom\":true,\"width\":800,\"xrange\":[-10,10],\"yrange\":[-10,10]}}],\"data\":{\"178c614d-0e82-4b7a-9dc2-a081206bc196\":[{\"a\":1,\"b\":2},{\"a\":2,\"b\":4},{\"a\":3,\"b\":6}],\"ff20f4a8-f3c9-4103-9fa6-3ffc7204d9e2\":[{\"a\":4,\"b\":1},{\"a\":5,\"b\":3},{\"a\":6,\"b\":5}],\"5f2efc6f-a1a2-40a5-84dc-88b900e1cded\":[{\"a\":7,\"b\":6},{\"a\":8,\"b\":4},{\"a\":9,\"b\":3}]},\"extension\":[]}\n",
1324
+ " var id_name = '#vis-12367786-a326-4f34-866f-84391cf29311';\n",
1325
+ " Nyaplot.core.parse(model, id_name);\n",
1326
+ "\n",
1327
+ " require(['downloadable'], function(downloadable){\n",
1328
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1329
+ "\t if(!svg.empty())\n",
1330
+ "\t svg.call(downloadable().filename('fig'));\n",
1331
+ "\t});\n",
1332
+ " };\n",
1333
+ " if(window['Nyaplot']==undefined){\n",
1334
+ " window.addEventListener('load_nyaplot', render, false);\n",
1335
+ "\treturn;\n",
1336
+ " } else {\n",
1337
+ " render();\n",
1338
+ " }\n",
1339
+ "})();\n",
1340
+ "</script>\n"
1341
+ ],
1342
+ "text/plain": [
1343
+ "#<Nyaplot::Plot:0x007fd05c054270 @properties={:diagrams=>[#<Nyaplot::Diagram:0x007fd05c01c730 @properties={:type=>:line, :options=>{:x=>:a, :y=>:b, :title=>\"I\", :stroke_width=>2}, :data=>\"178c614d-0e82-4b7a-9dc2-a081206bc196\"}, @xrange=[1, 3], @yrange=[2, 6]>, #<Nyaplot::Diagram:0x007fd05c84eb60 @properties={:type=>:line, :options=>{:x=>:a, :y=>:b, :title=>\"II\", :stroke_width=>4}, :data=>\"ff20f4a8-f3c9-4103-9fa6-3ffc7204d9e2\"}, @xrange=[4, 6], @yrange=[1, 5]>, #<Nyaplot::Diagram:0x007fd05b0180f0 @properties={:type=>:line, :options=>{:x=>:a, :y=>:b, :title=>\"III\", :stroke_width=>6}, :data=>\"5f2efc6f-a1a2-40a5-84dc-88b900e1cded\"}, @xrange=[7, 9], @yrange=[3, 6]>], :options=>{:legend=>true, :zoom=>true, :width=>800, :xrange=>[-10, 10], :yrange=>[-10, 10]}}>"
1344
+ ]
1345
+ },
1346
+ "execution_count": 34,
1347
+ "metadata": {},
1348
+ "output_type": "execute_result"
1349
+ }
1350
+ ],
1351
+ "source": [
1352
+ "line_2 = Daru::View::Plot.new(df, type: :line, x: :a, y: :b, categorized: {by: :c, method: :stroke_width})\n",
1353
+ "line_2.show_in_iruby\n",
1354
+ "line_2.chart.xrange [-10, 10]\n",
1355
+ "line_2.chart.yrange [-10, 10]"
1356
+ ]
1357
+ },
1358
+ {
1359
+ "cell_type": "code",
1360
+ "execution_count": null,
1361
+ "metadata": {
1362
+ "collapsed": true
1363
+ },
1364
+ "outputs": [],
1365
+ "source": []
1366
+ }
1367
+ ],
1368
+ "metadata": {
1369
+ "kernelspec": {
1370
+ "display_name": "Ruby 2.3.1",
1371
+ "language": "ruby",
1372
+ "name": "ruby"
1373
+ },
1374
+ "language_info": {
1375
+ "file_extension": ".rb",
1376
+ "mimetype": "application/x-ruby",
1377
+ "name": "ruby",
1378
+ "version": "2.3.1"
1379
+ }
1380
+ },
1381
+ "nbformat": 4,
1382
+ "nbformat_minor": 2
1383
+ }