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,1390 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "Note : Examples are taken from daru : http://nbviewer.jupyter.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Plotting/Visualization.ipynb"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": 1,
13
+ "metadata": {
14
+ "collapsed": false
15
+ },
16
+ "outputs": [
17
+ {
18
+ "name": "stderr",
19
+ "output_type": "stream",
20
+ "text": [
21
+ "\n",
22
+ "Install the spreadsheet gem version ~>1.1.1 for using spreadsheet functions.\n",
23
+ "\n",
24
+ "Install the mechanize gem version ~>2.7.5 for using mechanize functions.\n"
25
+ ]
26
+ },
27
+ {
28
+ "data": {
29
+ "text/plain": [
30
+ "true"
31
+ ]
32
+ },
33
+ "execution_count": 1,
34
+ "metadata": {},
35
+ "output_type": "execute_result"
36
+ }
37
+ ],
38
+ "source": [
39
+ "require 'daru/view'"
40
+ ]
41
+ },
42
+ {
43
+ "cell_type": "code",
44
+ "execution_count": 6,
45
+ "metadata": {
46
+ "collapsed": false
47
+ },
48
+ "outputs": [
49
+ {
50
+ "data": {
51
+ "application/javascript": [
52
+ "if(window['d3'] === undefined ||\n",
53
+ " window['Nyaplot'] === undefined){\n",
54
+ " 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",
55
+ "\n",
56
+ "\n",
57
+ "\n",
58
+ " var shim = {\"d3\":{\"exports\":\"d3\"},\"downloadable\":{\"exports\":\"downloadable\"}};\n",
59
+ "\n",
60
+ " require.config({paths: path, shim:shim});\n",
61
+ "\n",
62
+ "\n",
63
+ "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",
64
+ "\n",
65
+ "\tvar script = d3.select(\"head\")\n",
66
+ "\t .append(\"script\")\n",
67
+ "\t .attr(\"src\", \"http://cdn.rawgit.com/domitry/Nyaplotjs/master/release/nyaplot.js\")\n",
68
+ "\t .attr(\"async\", true);\n",
69
+ "\n",
70
+ "\tscript[0][0].onload = script[0][0].onreadystatechange = function(){\n",
71
+ "\n",
72
+ "\n",
73
+ "\t var event = document.createEvent(\"HTMLEvents\");\n",
74
+ "\t event.initEvent(\"load_nyaplot\",false,false);\n",
75
+ "\t window.dispatchEvent(event);\n",
76
+ "\t console.log('Finished loading Nyaplotjs');\n",
77
+ "\n",
78
+ "\t};\n",
79
+ "\n",
80
+ "\n",
81
+ "});});\n",
82
+ "}\n"
83
+ ],
84
+ "text/plain": [
85
+ "\"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\""
86
+ ]
87
+ },
88
+ "metadata": {},
89
+ "output_type": "display_data"
90
+ },
91
+ {
92
+ "data": {
93
+ "text/plain": [
94
+ ":nyaplot"
95
+ ]
96
+ },
97
+ "execution_count": 6,
98
+ "metadata": {},
99
+ "output_type": "execute_result"
100
+ }
101
+ ],
102
+ "source": [
103
+ "Daru::View.plotting_library = :nyaplot"
104
+ ]
105
+ },
106
+ {
107
+ "cell_type": "markdown",
108
+ "metadata": {},
109
+ "source": [
110
+ "# Categorical Vector Visualization"
111
+ ]
112
+ },
113
+ {
114
+ "cell_type": "code",
115
+ "execution_count": 7,
116
+ "metadata": {
117
+ "collapsed": false
118
+ },
119
+ "outputs": [
120
+ {
121
+ "data": {
122
+ "text/html": [
123
+ "<table>\n",
124
+ " <tr>\n",
125
+ " <th colspan=\"2\">Daru::Vector(6):category</th>\n",
126
+ " </tr>\n",
127
+ " \n",
128
+ "\n",
129
+ " \n",
130
+ " <tr>\n",
131
+ " <td>0</td>\n",
132
+ " <td>a</td>\n",
133
+ " </tr>\n",
134
+ " \n",
135
+ " <tr>\n",
136
+ " <td>1</td>\n",
137
+ " <td>a</td>\n",
138
+ " </tr>\n",
139
+ " \n",
140
+ " <tr>\n",
141
+ " <td>2</td>\n",
142
+ " <td>a</td>\n",
143
+ " </tr>\n",
144
+ " \n",
145
+ " <tr>\n",
146
+ " <td>3</td>\n",
147
+ " <td>b</td>\n",
148
+ " </tr>\n",
149
+ " \n",
150
+ " <tr>\n",
151
+ " <td>4</td>\n",
152
+ " <td>b</td>\n",
153
+ " </tr>\n",
154
+ " \n",
155
+ " <tr>\n",
156
+ " <td>5</td>\n",
157
+ " <td>c</td>\n",
158
+ " </tr>\n",
159
+ " \n",
160
+ "\n",
161
+ " \n",
162
+ "</table>"
163
+ ],
164
+ "text/plain": [
165
+ "#<Daru::Vector(6):cataegory>\n",
166
+ " 0 a\n",
167
+ " 1 a\n",
168
+ " 2 a\n",
169
+ " 3 b\n",
170
+ " 4 b\n",
171
+ " 5 c"
172
+ ]
173
+ },
174
+ "execution_count": 7,
175
+ "metadata": {},
176
+ "output_type": "execute_result"
177
+ }
178
+ ],
179
+ "source": [
180
+ "dv = Daru::Vector.new [:a, :a, :a, :b, :b, :c], type: :category"
181
+ ]
182
+ },
183
+ {
184
+ "cell_type": "markdown",
185
+ "metadata": {},
186
+ "source": [
187
+ "### Bar graph\n",
188
+ "\n",
189
+ "##### 1. Frequency (count)"
190
+ ]
191
+ },
192
+ {
193
+ "cell_type": "code",
194
+ "execution_count": 8,
195
+ "metadata": {
196
+ "collapsed": false
197
+ },
198
+ "outputs": [
199
+ {
200
+ "data": {
201
+ "text/plain": [
202
+ "#<Daru::View::Plot:0x007fd05c935a10 @data=#<Daru::Vector(6):cataegory>\n",
203
+ " 0 a\n",
204
+ " 1 a\n",
205
+ " 2 a\n",
206
+ " 3 b\n",
207
+ " 4 b\n",
208
+ " 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=>{}}>>"
209
+ ]
210
+ },
211
+ "execution_count": 8,
212
+ "metadata": {},
213
+ "output_type": "execute_result"
214
+ }
215
+ ],
216
+ "source": [
217
+ "bar_graph1 = Daru::View::Plot.new(dv, type: :bar)"
218
+ ]
219
+ },
220
+ {
221
+ "cell_type": "code",
222
+ "execution_count": 9,
223
+ "metadata": {
224
+ "collapsed": false
225
+ },
226
+ "outputs": [
227
+ {
228
+ "data": {
229
+ "text/plain": [
230
+ "Nyaplot::Plot"
231
+ ]
232
+ },
233
+ "execution_count": 9,
234
+ "metadata": {},
235
+ "output_type": "execute_result"
236
+ }
237
+ ],
238
+ "source": [
239
+ "bar_graph1.chart.class"
240
+ ]
241
+ },
242
+ {
243
+ "cell_type": "code",
244
+ "execution_count": 10,
245
+ "metadata": {
246
+ "collapsed": false
247
+ },
248
+ "outputs": [
249
+ {
250
+ "data": {
251
+ "text/html": [
252
+ "<div id='vis-a9909bc7-df51-4925-af63-73de4372f3be'></div>\n",
253
+ "<script>\n",
254
+ "(function(){\n",
255
+ " var render = function(){\n",
256
+ " 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",
257
+ " var id_name = '#vis-a9909bc7-df51-4925-af63-73de4372f3be';\n",
258
+ " Nyaplot.core.parse(model, id_name);\n",
259
+ "\n",
260
+ " require(['downloadable'], function(downloadable){\n",
261
+ " var svg = d3.select(id_name).select(\"svg\");\n",
262
+ "\t if(!svg.empty())\n",
263
+ "\t svg.call(downloadable().filename('fig'));\n",
264
+ "\t});\n",
265
+ " };\n",
266
+ " if(window['Nyaplot']==undefined){\n",
267
+ " window.addEventListener('load_nyaplot', render, false);\n",
268
+ "\treturn;\n",
269
+ " } else {\n",
270
+ " render();\n",
271
+ " }\n",
272
+ "})();\n",
273
+ "</script>\n"
274
+ ],
275
+ "text/plain": [
276
+ "#<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=>[]}>"
277
+ ]
278
+ },
279
+ "metadata": {},
280
+ "output_type": "display_data"
281
+ }
282
+ ],
283
+ "source": [
284
+ "bar_graph1.show_in_iruby"
285
+ ]
286
+ },
287
+ {
288
+ "cell_type": "code",
289
+ "execution_count": 11,
290
+ "metadata": {
291
+ "collapsed": false
292
+ },
293
+ "outputs": [
294
+ {
295
+ "data": {
296
+ "text/plain": [
297
+ ":category"
298
+ ]
299
+ },
300
+ "execution_count": 11,
301
+ "metadata": {},
302
+ "output_type": "execute_result"
303
+ }
304
+ ],
305
+ "source": [
306
+ "dv = Daru::Vector.new ['III']*10 + ['II']*5 + ['I']*5, type: :category, categories: ['I', 'II', 'III']\n",
307
+ "dv.type"
308
+ ]
309
+ },
310
+ {
311
+ "cell_type": "code",
312
+ "execution_count": 12,
313
+ "metadata": {
314
+ "collapsed": false
315
+ },
316
+ "outputs": [
317
+ {
318
+ "data": {
319
+ "text/plain": [
320
+ "#<Daru::View::Plot:0x007fd05b2faf20 @data=#<Daru::Vector(20):cataegory>\n",
321
+ " 0 III\n",
322
+ " 1 III\n",
323
+ " 2 III\n",
324
+ " 3 III\n",
325
+ " 4 III\n",
326
+ " 5 III\n",
327
+ " 6 III\n",
328
+ " 7 III\n",
329
+ " 8 III\n",
330
+ " 9 III\n",
331
+ " 10 II\n",
332
+ " 11 II\n",
333
+ " 12 II\n",
334
+ " 13 II\n",
335
+ " 14 II\n",
336
+ " ... ..., @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=>{}}>>"
337
+ ]
338
+ },
339
+ "execution_count": 12,
340
+ "metadata": {},
341
+ "output_type": "execute_result"
342
+ }
343
+ ],
344
+ "source": [
345
+ "bar_graph2 = Daru::View::Plot.new(dv, type: :bar)"
346
+ ]
347
+ },
348
+ {
349
+ "cell_type": "code",
350
+ "execution_count": 13,
351
+ "metadata": {
352
+ "collapsed": false
353
+ },
354
+ "outputs": [
355
+ {
356
+ "data": {
357
+ "text/plain": [
358
+ "Daru::View::Plot"
359
+ ]
360
+ },
361
+ "execution_count": 13,
362
+ "metadata": {},
363
+ "output_type": "execute_result"
364
+ }
365
+ ],
366
+ "source": [
367
+ "bar_graph2.class"
368
+ ]
369
+ },
370
+ {
371
+ "cell_type": "code",
372
+ "execution_count": 14,
373
+ "metadata": {
374
+ "collapsed": false
375
+ },
376
+ "outputs": [
377
+ {
378
+ "data": {
379
+ "text/plain": [
380
+ "Nyaplot::Plot"
381
+ ]
382
+ },
383
+ "execution_count": 14,
384
+ "metadata": {},
385
+ "output_type": "execute_result"
386
+ }
387
+ ],
388
+ "source": [
389
+ "bar_graph2.chart.class"
390
+ ]
391
+ },
392
+ {
393
+ "cell_type": "code",
394
+ "execution_count": 15,
395
+ "metadata": {
396
+ "collapsed": false
397
+ },
398
+ "outputs": [
399
+ {
400
+ "data": {
401
+ "text/html": [
402
+ "<div id='vis-06549f53-653c-4dc4-a7fe-d0ceb3a80658'></div>\n",
403
+ "<script>\n",
404
+ "(function(){\n",
405
+ " var render = function(){\n",
406
+ " 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",
407
+ " var id_name = '#vis-06549f53-653c-4dc4-a7fe-d0ceb3a80658';\n",
408
+ " Nyaplot.core.parse(model, id_name);\n",
409
+ "\n",
410
+ " require(['downloadable'], function(downloadable){\n",
411
+ " var svg = d3.select(id_name).select(\"svg\");\n",
412
+ "\t if(!svg.empty())\n",
413
+ "\t svg.call(downloadable().filename('fig'));\n",
414
+ "\t});\n",
415
+ " };\n",
416
+ " if(window['Nyaplot']==undefined){\n",
417
+ " window.addEventListener('load_nyaplot', render, false);\n",
418
+ "\treturn;\n",
419
+ " } else {\n",
420
+ " render();\n",
421
+ " }\n",
422
+ "})();\n",
423
+ "</script>\n"
424
+ ],
425
+ "text/plain": [
426
+ "#<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]}}>"
427
+ ]
428
+ },
429
+ "execution_count": 15,
430
+ "metadata": {},
431
+ "output_type": "execute_result"
432
+ }
433
+ ],
434
+ "source": [
435
+ "# Nyaplot methods will work.Since #chart is Nyaplot::Plot class object\n",
436
+ "bar_graph2.chart.x_label 'Cat'\n",
437
+ "bar_graph2.chart.y_label 'Frequency'"
438
+ ]
439
+ },
440
+ {
441
+ "cell_type": "code",
442
+ "execution_count": 16,
443
+ "metadata": {
444
+ "collapsed": false
445
+ },
446
+ "outputs": [
447
+ {
448
+ "data": {
449
+ "text/html": [
450
+ "<div id='vis-39949ceb-290a-46cb-bc6f-4a7c37f15ed5'></div>\n",
451
+ "<script>\n",
452
+ "(function(){\n",
453
+ " var render = function(){\n",
454
+ " 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",
455
+ " var id_name = '#vis-39949ceb-290a-46cb-bc6f-4a7c37f15ed5';\n",
456
+ " Nyaplot.core.parse(model, id_name);\n",
457
+ "\n",
458
+ " require(['downloadable'], function(downloadable){\n",
459
+ " var svg = d3.select(id_name).select(\"svg\");\n",
460
+ "\t if(!svg.empty())\n",
461
+ "\t svg.call(downloadable().filename('fig'));\n",
462
+ "\t});\n",
463
+ " };\n",
464
+ " if(window['Nyaplot']==undefined){\n",
465
+ " window.addEventListener('load_nyaplot', render, false);\n",
466
+ "\treturn;\n",
467
+ " } else {\n",
468
+ " render();\n",
469
+ " }\n",
470
+ "})();\n",
471
+ "</script>\n"
472
+ ],
473
+ "text/plain": [
474
+ "#<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]}}>"
475
+ ]
476
+ },
477
+ "execution_count": 16,
478
+ "metadata": {},
479
+ "output_type": "execute_result"
480
+ }
481
+ ],
482
+ "source": [
483
+ "bar_graph2.chart # or bar_graph2.show_in_iruby"
484
+ ]
485
+ },
486
+ {
487
+ "cell_type": "markdown",
488
+ "metadata": {},
489
+ "source": [
490
+ "#### 2. Percentage"
491
+ ]
492
+ },
493
+ {
494
+ "cell_type": "code",
495
+ "execution_count": 17,
496
+ "metadata": {
497
+ "collapsed": false
498
+ },
499
+ "outputs": [
500
+ {
501
+ "data": {
502
+ "text/plain": [
503
+ "#<Daru::View::Plot:0x007fd05c34a678 @data=#<Daru::Vector(20):cataegory>\n",
504
+ " 0 III\n",
505
+ " 1 III\n",
506
+ " 2 III\n",
507
+ " 3 III\n",
508
+ " 4 III\n",
509
+ " 5 III\n",
510
+ " 6 III\n",
511
+ " 7 III\n",
512
+ " 8 III\n",
513
+ " 9 III\n",
514
+ " 10 II\n",
515
+ " 11 II\n",
516
+ " 12 II\n",
517
+ " 13 II\n",
518
+ " 14 II\n",
519
+ " ... ..., @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]}}>>"
520
+ ]
521
+ },
522
+ "execution_count": 17,
523
+ "metadata": {},
524
+ "output_type": "execute_result"
525
+ }
526
+ ],
527
+ "source": [
528
+ "bar_graph2_per = Daru::View::Plot.new(dv, type: :bar, method: :percentage)"
529
+ ]
530
+ },
531
+ {
532
+ "cell_type": "code",
533
+ "execution_count": 18,
534
+ "metadata": {
535
+ "collapsed": false
536
+ },
537
+ "outputs": [
538
+ {
539
+ "data": {
540
+ "text/html": [
541
+ "<div id='vis-d7b0494c-0239-442a-ac66-30ab74e04196'></div>\n",
542
+ "<script>\n",
543
+ "(function(){\n",
544
+ " var render = function(){\n",
545
+ " 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",
546
+ " var id_name = '#vis-d7b0494c-0239-442a-ac66-30ab74e04196';\n",
547
+ " Nyaplot.core.parse(model, id_name);\n",
548
+ "\n",
549
+ " require(['downloadable'], function(downloadable){\n",
550
+ " var svg = d3.select(id_name).select(\"svg\");\n",
551
+ "\t if(!svg.empty())\n",
552
+ "\t svg.call(downloadable().filename('fig'));\n",
553
+ "\t});\n",
554
+ " };\n",
555
+ " if(window['Nyaplot']==undefined){\n",
556
+ " window.addEventListener('load_nyaplot', render, false);\n",
557
+ "\treturn;\n",
558
+ " } else {\n",
559
+ " render();\n",
560
+ " }\n",
561
+ "})();\n",
562
+ "</script>\n"
563
+ ],
564
+ "text/plain": [
565
+ "#<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=>[]}>"
566
+ ]
567
+ },
568
+ "metadata": {},
569
+ "output_type": "display_data"
570
+ }
571
+ ],
572
+ "source": [
573
+ "bar_graph2_per.chart.x_label 'Categories'\n",
574
+ "bar_graph2_per.chart.y_label 'Percentage (%)'\n",
575
+ "bar_graph2_per.show_in_iruby"
576
+ ]
577
+ },
578
+ {
579
+ "cell_type": "markdown",
580
+ "metadata": {},
581
+ "source": [
582
+ "#### 3. Fraction"
583
+ ]
584
+ },
585
+ {
586
+ "cell_type": "code",
587
+ "execution_count": 19,
588
+ "metadata": {
589
+ "collapsed": false
590
+ },
591
+ "outputs": [
592
+ {
593
+ "data": {
594
+ "text/plain": [
595
+ "#<Daru::View::Plot:0x007fd05ca92c28 @data=#<Daru::Vector(20):cataegory>\n",
596
+ " 0 III\n",
597
+ " 1 III\n",
598
+ " 2 III\n",
599
+ " 3 III\n",
600
+ " 4 III\n",
601
+ " 5 III\n",
602
+ " 6 III\n",
603
+ " 7 III\n",
604
+ " 8 III\n",
605
+ " 9 III\n",
606
+ " 10 II\n",
607
+ " 11 II\n",
608
+ " 12 II\n",
609
+ " 13 II\n",
610
+ " 14 II\n",
611
+ " ... ..., @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]}}>>"
612
+ ]
613
+ },
614
+ "execution_count": 19,
615
+ "metadata": {},
616
+ "output_type": "execute_result"
617
+ }
618
+ ],
619
+ "source": [
620
+ "bar_graph2_frac = Daru::View::Plot.new(dv, type: :bar, method: :fraction)"
621
+ ]
622
+ },
623
+ {
624
+ "cell_type": "code",
625
+ "execution_count": 20,
626
+ "metadata": {
627
+ "collapsed": false
628
+ },
629
+ "outputs": [
630
+ {
631
+ "data": {
632
+ "text/html": [
633
+ "<div id='vis-24075e1a-c2c6-418c-a960-1226d92ee0b2'></div>\n",
634
+ "<script>\n",
635
+ "(function(){\n",
636
+ " var render = function(){\n",
637
+ " 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",
638
+ " var id_name = '#vis-24075e1a-c2c6-418c-a960-1226d92ee0b2';\n",
639
+ " Nyaplot.core.parse(model, id_name);\n",
640
+ "\n",
641
+ " require(['downloadable'], function(downloadable){\n",
642
+ " var svg = d3.select(id_name).select(\"svg\");\n",
643
+ "\t if(!svg.empty())\n",
644
+ "\t svg.call(downloadable().filename('fig'));\n",
645
+ "\t});\n",
646
+ " };\n",
647
+ " if(window['Nyaplot']==undefined){\n",
648
+ " window.addEventListener('load_nyaplot', render, false);\n",
649
+ "\treturn;\n",
650
+ " } else {\n",
651
+ " render();\n",
652
+ " }\n",
653
+ "})();\n",
654
+ "</script>\n"
655
+ ],
656
+ "text/plain": [
657
+ "#<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=>[]}>"
658
+ ]
659
+ },
660
+ "metadata": {},
661
+ "output_type": "display_data"
662
+ }
663
+ ],
664
+ "source": [
665
+ "# bar_graph2_frac.chart.x_label 'Categories'\n",
666
+ "bar_graph2_frac.chart.y_label 'Fraction'\n",
667
+ "bar_graph2_frac.show_in_iruby"
668
+ ]
669
+ },
670
+ {
671
+ "cell_type": "markdown",
672
+ "metadata": {},
673
+ "source": [
674
+ "# Categorical data visualization in Dataframe\n",
675
+ "### Bar Graph"
676
+ ]
677
+ },
678
+ {
679
+ "cell_type": "code",
680
+ "execution_count": 21,
681
+ "metadata": {
682
+ "collapsed": false
683
+ },
684
+ "outputs": [
685
+ {
686
+ "data": {
687
+ "text/plain": [
688
+ ":category"
689
+ ]
690
+ },
691
+ "execution_count": 21,
692
+ "metadata": {},
693
+ "output_type": "execute_result"
694
+ }
695
+ ],
696
+ "source": [
697
+ "df = Daru::DataFrame.new({\n",
698
+ " a: [1, 2, 4, -2, 5, 23, 0],\n",
699
+ " b: [3, 1, 3, -6, 2, 1, 0],\n",
700
+ " c: ['I', 'II', 'I', 'III', 'I', 'III', 'II']\n",
701
+ " })\n",
702
+ "df.to_category :c\n",
703
+ "df[:c].type"
704
+ ]
705
+ },
706
+ {
707
+ "cell_type": "code",
708
+ "execution_count": 22,
709
+ "metadata": {
710
+ "collapsed": false
711
+ },
712
+ "outputs": [
713
+ {
714
+ "data": {
715
+ "text/plain": [
716
+ "#<Daru::View::Plot:0x007fd05bb12140 @data=#<Daru::DataFrame(7x3)>\n",
717
+ " a b c\n",
718
+ " 0 1 3 I\n",
719
+ " 1 2 1 II\n",
720
+ " 2 4 3 I\n",
721
+ " 3 -2 -6 III\n",
722
+ " 4 5 2 I\n",
723
+ " 5 23 1 III\n",
724
+ " 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=>{}}>>"
725
+ ]
726
+ },
727
+ "execution_count": 22,
728
+ "metadata": {},
729
+ "output_type": "execute_result"
730
+ }
731
+ ],
732
+ "source": [
733
+ "bar_graph3 = Daru::View::Plot.new(df, type: :bar, x: :c)"
734
+ ]
735
+ },
736
+ {
737
+ "cell_type": "code",
738
+ "execution_count": 23,
739
+ "metadata": {
740
+ "collapsed": false
741
+ },
742
+ "outputs": [
743
+ {
744
+ "data": {
745
+ "text/html": [
746
+ "<div id='vis-703fc484-9142-435a-845d-9b86f5ed0622'></div>\n",
747
+ "<script>\n",
748
+ "(function(){\n",
749
+ " var render = function(){\n",
750
+ " 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",
751
+ " var id_name = '#vis-703fc484-9142-435a-845d-9b86f5ed0622';\n",
752
+ " Nyaplot.core.parse(model, id_name);\n",
753
+ "\n",
754
+ " require(['downloadable'], function(downloadable){\n",
755
+ " var svg = d3.select(id_name).select(\"svg\");\n",
756
+ "\t if(!svg.empty())\n",
757
+ "\t svg.call(downloadable().filename('fig'));\n",
758
+ "\t});\n",
759
+ " };\n",
760
+ " if(window['Nyaplot']==undefined){\n",
761
+ " window.addEventListener('load_nyaplot', render, false);\n",
762
+ "\treturn;\n",
763
+ " } else {\n",
764
+ " render();\n",
765
+ " }\n",
766
+ "})();\n",
767
+ "</script>\n"
768
+ ],
769
+ "text/plain": [
770
+ "#<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=>[]}>"
771
+ ]
772
+ },
773
+ "metadata": {},
774
+ "output_type": "display_data"
775
+ }
776
+ ],
777
+ "source": [
778
+ "bar_graph3.show_in_iruby"
779
+ ]
780
+ },
781
+ {
782
+ "cell_type": "markdown",
783
+ "metadata": {},
784
+ "source": [
785
+ "### Scatter plot categorized by categorical variable¶\n",
786
+ "#### Plots can be categorized by\n",
787
+ "\n",
788
+ "- Color\n",
789
+ "- Size\n",
790
+ "- Shape"
791
+ ]
792
+ },
793
+ {
794
+ "cell_type": "code",
795
+ "execution_count": 24,
796
+ "metadata": {
797
+ "collapsed": false
798
+ },
799
+ "outputs": [
800
+ {
801
+ "data": {
802
+ "text/plain": [
803
+ ":category"
804
+ ]
805
+ },
806
+ "execution_count": 24,
807
+ "metadata": {},
808
+ "output_type": "execute_result"
809
+ }
810
+ ],
811
+ "source": [
812
+ "df = Daru::DataFrame.new({\n",
813
+ " a: [1, 2, 4, -2, 5, 23, 0],\n",
814
+ " b: [3, 1, 3, -6, 2, 1, 0],\n",
815
+ " c: ['I', 'II', 'I', 'III', 'I', 'III', 'II']\n",
816
+ " })\n",
817
+ "df.to_category :c\n",
818
+ "df[:c].type"
819
+ ]
820
+ },
821
+ {
822
+ "cell_type": "code",
823
+ "execution_count": 25,
824
+ "metadata": {
825
+ "collapsed": false
826
+ },
827
+ "outputs": [
828
+ {
829
+ "data": {
830
+ "text/plain": [
831
+ "#<Daru::View::Plot:0x007fd05bac9af8 @data=#<Daru::DataFrame(7x3)>\n",
832
+ " a b c\n",
833
+ " 0 1 3 I\n",
834
+ " 1 2 1 II\n",
835
+ " 2 4 3 I\n",
836
+ " 3 -2 -6 III\n",
837
+ " 4 5 2 I\n",
838
+ " 5 23 1 III\n",
839
+ " 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}}>>"
840
+ ]
841
+ },
842
+ "execution_count": 25,
843
+ "metadata": {},
844
+ "output_type": "execute_result"
845
+ }
846
+ ],
847
+ "source": [
848
+ "scatter_1 = Daru::View::Plot.new(df, type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :color})"
849
+ ]
850
+ },
851
+ {
852
+ "cell_type": "code",
853
+ "execution_count": 26,
854
+ "metadata": {
855
+ "collapsed": false,
856
+ "scrolled": true
857
+ },
858
+ "outputs": [
859
+ {
860
+ "data": {
861
+ "text/html": [
862
+ "<div id='vis-fdaf3017-dba7-481a-8e9e-4b18ef0f7d74'></div>\n",
863
+ "<script>\n",
864
+ "(function(){\n",
865
+ " var render = function(){\n",
866
+ " 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",
867
+ " var id_name = '#vis-fdaf3017-dba7-481a-8e9e-4b18ef0f7d74';\n",
868
+ " Nyaplot.core.parse(model, id_name);\n",
869
+ "\n",
870
+ " require(['downloadable'], function(downloadable){\n",
871
+ " var svg = d3.select(id_name).select(\"svg\");\n",
872
+ "\t if(!svg.empty())\n",
873
+ "\t svg.call(downloadable().filename('fig'));\n",
874
+ "\t});\n",
875
+ " };\n",
876
+ " if(window['Nyaplot']==undefined){\n",
877
+ " window.addEventListener('load_nyaplot', render, false);\n",
878
+ "\treturn;\n",
879
+ " } else {\n",
880
+ " render();\n",
881
+ " }\n",
882
+ "})();\n",
883
+ "</script>\n"
884
+ ],
885
+ "text/plain": [
886
+ "#<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=>[]}>"
887
+ ]
888
+ },
889
+ "metadata": {},
890
+ "output_type": "display_data"
891
+ }
892
+ ],
893
+ "source": [
894
+ "scatter_1.show_in_iruby"
895
+ ]
896
+ },
897
+ {
898
+ "cell_type": "code",
899
+ "execution_count": 27,
900
+ "metadata": {
901
+ "collapsed": false
902
+ },
903
+ "outputs": [
904
+ {
905
+ "data": {
906
+ "text/html": [
907
+ "<div id='vis-d8fdb108-862a-4e6e-bb6a-6a17a6f07ad9'></div>\n",
908
+ "<script>\n",
909
+ "(function(){\n",
910
+ " var render = function(){\n",
911
+ " 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",
912
+ " var id_name = '#vis-d8fdb108-862a-4e6e-bb6a-6a17a6f07ad9';\n",
913
+ " Nyaplot.core.parse(model, id_name);\n",
914
+ "\n",
915
+ " require(['downloadable'], function(downloadable){\n",
916
+ " var svg = d3.select(id_name).select(\"svg\");\n",
917
+ "\t if(!svg.empty())\n",
918
+ "\t svg.call(downloadable().filename('fig'));\n",
919
+ "\t});\n",
920
+ " };\n",
921
+ " if(window['Nyaplot']==undefined){\n",
922
+ " window.addEventListener('load_nyaplot', render, false);\n",
923
+ "\treturn;\n",
924
+ " } else {\n",
925
+ " render();\n",
926
+ " }\n",
927
+ "})();\n",
928
+ "</script>\n"
929
+ ],
930
+ "text/plain": [
931
+ "#<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]}}>"
932
+ ]
933
+ },
934
+ "execution_count": 27,
935
+ "metadata": {},
936
+ "output_type": "execute_result"
937
+ }
938
+ ],
939
+ "source": [
940
+ "scatter_1.chart.xrange [-10, 10]\n",
941
+ "scatter_1.chart.yrange [-10, 10]"
942
+ ]
943
+ },
944
+ {
945
+ "cell_type": "code",
946
+ "execution_count": 28,
947
+ "metadata": {
948
+ "collapsed": false
949
+ },
950
+ "outputs": [
951
+ {
952
+ "data": {
953
+ "text/html": [
954
+ "<div id='vis-8a4277f1-830d-46bd-aa71-dd55b4385772'></div>\n",
955
+ "<script>\n",
956
+ "(function(){\n",
957
+ " var render = function(){\n",
958
+ " 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",
959
+ " var id_name = '#vis-8a4277f1-830d-46bd-aa71-dd55b4385772';\n",
960
+ " Nyaplot.core.parse(model, id_name);\n",
961
+ "\n",
962
+ " require(['downloadable'], function(downloadable){\n",
963
+ " var svg = d3.select(id_name).select(\"svg\");\n",
964
+ "\t if(!svg.empty())\n",
965
+ "\t svg.call(downloadable().filename('fig'));\n",
966
+ "\t});\n",
967
+ " };\n",
968
+ " if(window['Nyaplot']==undefined){\n",
969
+ " window.addEventListener('load_nyaplot', render, false);\n",
970
+ "\treturn;\n",
971
+ " } else {\n",
972
+ " render();\n",
973
+ " }\n",
974
+ "})();\n",
975
+ "</script>\n"
976
+ ],
977
+ "text/plain": [
978
+ "#<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=>[]}>"
979
+ ]
980
+ },
981
+ "metadata": {},
982
+ "output_type": "display_data"
983
+ }
984
+ ],
985
+ "source": [
986
+ "scatter_2 = Daru::View::Plot.new(df, type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :shape})\n",
987
+ "scatter_2.show_in_iruby"
988
+ ]
989
+ },
990
+ {
991
+ "cell_type": "code",
992
+ "execution_count": 29,
993
+ "metadata": {
994
+ "collapsed": false
995
+ },
996
+ "outputs": [
997
+ {
998
+ "data": {
999
+ "text/html": [
1000
+ "<div id='vis-c959743a-7a5f-472a-9399-2eb8bb4b0978'></div>\n",
1001
+ "<script>\n",
1002
+ "(function(){\n",
1003
+ " var render = function(){\n",
1004
+ " 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",
1005
+ " var id_name = '#vis-c959743a-7a5f-472a-9399-2eb8bb4b0978';\n",
1006
+ " Nyaplot.core.parse(model, id_name);\n",
1007
+ "\n",
1008
+ " require(['downloadable'], function(downloadable){\n",
1009
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1010
+ "\t if(!svg.empty())\n",
1011
+ "\t svg.call(downloadable().filename('fig'));\n",
1012
+ "\t});\n",
1013
+ " };\n",
1014
+ " if(window['Nyaplot']==undefined){\n",
1015
+ " window.addEventListener('load_nyaplot', render, false);\n",
1016
+ "\treturn;\n",
1017
+ " } else {\n",
1018
+ " render();\n",
1019
+ " }\n",
1020
+ "})();\n",
1021
+ "</script>\n"
1022
+ ],
1023
+ "text/plain": [
1024
+ "#<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]}}>"
1025
+ ]
1026
+ },
1027
+ "execution_count": 29,
1028
+ "metadata": {},
1029
+ "output_type": "execute_result"
1030
+ }
1031
+ ],
1032
+ "source": [
1033
+ "scatter_2.chart.xrange [-10, 10]\n",
1034
+ "scatter_2.chart.yrange [-10, 10]"
1035
+ ]
1036
+ },
1037
+ {
1038
+ "cell_type": "code",
1039
+ "execution_count": 30,
1040
+ "metadata": {
1041
+ "collapsed": false
1042
+ },
1043
+ "outputs": [
1044
+ {
1045
+ "data": {
1046
+ "text/html": [
1047
+ "<div id='vis-a4e5b8fd-b9c6-4808-9297-8e1d0a08f17e'></div>\n",
1048
+ "<script>\n",
1049
+ "(function(){\n",
1050
+ " var render = function(){\n",
1051
+ " 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",
1052
+ " var id_name = '#vis-a4e5b8fd-b9c6-4808-9297-8e1d0a08f17e';\n",
1053
+ " Nyaplot.core.parse(model, id_name);\n",
1054
+ "\n",
1055
+ " require(['downloadable'], function(downloadable){\n",
1056
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1057
+ "\t if(!svg.empty())\n",
1058
+ "\t svg.call(downloadable().filename('fig'));\n",
1059
+ "\t});\n",
1060
+ " };\n",
1061
+ " if(window['Nyaplot']==undefined){\n",
1062
+ " window.addEventListener('load_nyaplot', render, false);\n",
1063
+ "\treturn;\n",
1064
+ " } else {\n",
1065
+ " render();\n",
1066
+ " }\n",
1067
+ "})();\n",
1068
+ "</script>\n"
1069
+ ],
1070
+ "text/plain": [
1071
+ "#<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=>[]}>"
1072
+ ]
1073
+ },
1074
+ "metadata": {},
1075
+ "output_type": "display_data"
1076
+ },
1077
+ {
1078
+ "data": {
1079
+ "text/html": [
1080
+ "<div id='vis-7eefae9c-5917-4cd4-ba89-77827220a672'></div>\n",
1081
+ "<script>\n",
1082
+ "(function(){\n",
1083
+ " var render = function(){\n",
1084
+ " 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",
1085
+ " var id_name = '#vis-7eefae9c-5917-4cd4-ba89-77827220a672';\n",
1086
+ " Nyaplot.core.parse(model, id_name);\n",
1087
+ "\n",
1088
+ " require(['downloadable'], function(downloadable){\n",
1089
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1090
+ "\t if(!svg.empty())\n",
1091
+ "\t svg.call(downloadable().filename('fig'));\n",
1092
+ "\t});\n",
1093
+ " };\n",
1094
+ " if(window['Nyaplot']==undefined){\n",
1095
+ " window.addEventListener('load_nyaplot', render, false);\n",
1096
+ "\treturn;\n",
1097
+ " } else {\n",
1098
+ " render();\n",
1099
+ " }\n",
1100
+ "})();\n",
1101
+ "</script>\n"
1102
+ ],
1103
+ "text/plain": [
1104
+ "#<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]}}>"
1105
+ ]
1106
+ },
1107
+ "execution_count": 30,
1108
+ "metadata": {},
1109
+ "output_type": "execute_result"
1110
+ }
1111
+ ],
1112
+ "source": [
1113
+ "scatter_3 = Daru::View::Plot.new(df, type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :color, color: [:red, :blue, :green]})\n",
1114
+ "scatter_3.show_in_iruby\n",
1115
+ "scatter_2.chart.xrange [-10, 10]\n",
1116
+ "scatter_2.chart.yrange [-10, 10]"
1117
+ ]
1118
+ },
1119
+ {
1120
+ "cell_type": "code",
1121
+ "execution_count": 31,
1122
+ "metadata": {
1123
+ "collapsed": false
1124
+ },
1125
+ "outputs": [
1126
+ {
1127
+ "data": {
1128
+ "text/html": [
1129
+ "<div id='vis-8ae12741-1caa-44e4-87c3-8adf87119c10'></div>\n",
1130
+ "<script>\n",
1131
+ "(function(){\n",
1132
+ " var render = function(){\n",
1133
+ " 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",
1134
+ " var id_name = '#vis-8ae12741-1caa-44e4-87c3-8adf87119c10';\n",
1135
+ " Nyaplot.core.parse(model, id_name);\n",
1136
+ "\n",
1137
+ " require(['downloadable'], function(downloadable){\n",
1138
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1139
+ "\t if(!svg.empty())\n",
1140
+ "\t svg.call(downloadable().filename('fig'));\n",
1141
+ "\t});\n",
1142
+ " };\n",
1143
+ " if(window['Nyaplot']==undefined){\n",
1144
+ " window.addEventListener('load_nyaplot', render, false);\n",
1145
+ "\treturn;\n",
1146
+ " } else {\n",
1147
+ " render();\n",
1148
+ " }\n",
1149
+ "})();\n",
1150
+ "</script>\n"
1151
+ ],
1152
+ "text/plain": [
1153
+ "#<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=>[]}>"
1154
+ ]
1155
+ },
1156
+ "metadata": {},
1157
+ "output_type": "display_data"
1158
+ },
1159
+ {
1160
+ "data": {
1161
+ "text/html": [
1162
+ "<div id='vis-5f9addad-0d19-47e0-95e3-929b47b873f0'></div>\n",
1163
+ "<script>\n",
1164
+ "(function(){\n",
1165
+ " var render = function(){\n",
1166
+ " 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",
1167
+ " var id_name = '#vis-5f9addad-0d19-47e0-95e3-929b47b873f0';\n",
1168
+ " Nyaplot.core.parse(model, id_name);\n",
1169
+ "\n",
1170
+ " require(['downloadable'], function(downloadable){\n",
1171
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1172
+ "\t if(!svg.empty())\n",
1173
+ "\t svg.call(downloadable().filename('fig'));\n",
1174
+ "\t});\n",
1175
+ " };\n",
1176
+ " if(window['Nyaplot']==undefined){\n",
1177
+ " window.addEventListener('load_nyaplot', render, false);\n",
1178
+ "\treturn;\n",
1179
+ " } else {\n",
1180
+ " render();\n",
1181
+ " }\n",
1182
+ "})();\n",
1183
+ "</script>\n"
1184
+ ],
1185
+ "text/plain": [
1186
+ "#<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]}}>"
1187
+ ]
1188
+ },
1189
+ "execution_count": 31,
1190
+ "metadata": {},
1191
+ "output_type": "execute_result"
1192
+ }
1193
+ ],
1194
+ "source": [
1195
+ "scatter_4 = Daru::View::Plot.new(df, type: :scatter, x: :a, y: :b, categorized: {by: :c, method: :size, size: [300, 600, 900]})\n",
1196
+ "scatter_4.show_in_iruby\n",
1197
+ "scatter_4.chart.xrange [-10, 10]\n",
1198
+ "scatter_4.chart.yrange [-10, 10]"
1199
+ ]
1200
+ },
1201
+ {
1202
+ "cell_type": "markdown",
1203
+ "metadata": {},
1204
+ "source": [
1205
+ "### Line plot categorized by categorical variable\n",
1206
+ "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."
1207
+ ]
1208
+ },
1209
+ {
1210
+ "cell_type": "code",
1211
+ "execution_count": 32,
1212
+ "metadata": {
1213
+ "collapsed": false
1214
+ },
1215
+ "outputs": [
1216
+ {
1217
+ "data": {
1218
+ "text/plain": [
1219
+ ":category"
1220
+ ]
1221
+ },
1222
+ "execution_count": 32,
1223
+ "metadata": {},
1224
+ "output_type": "execute_result"
1225
+ }
1226
+ ],
1227
+ "source": [
1228
+ "df = Daru::DataFrame.new({\n",
1229
+ " a: [1, 2, 3, 4, 5, 6, 7, 8, 9],\n",
1230
+ " b: [2, 4, 6, 1, 3, 5, 6, 4, 3],\n",
1231
+ " c: ['I']*3 + ['II']*3 + ['III']*3\n",
1232
+ " })\n",
1233
+ "df.to_category :c\n",
1234
+ "df[:c].type"
1235
+ ]
1236
+ },
1237
+ {
1238
+ "cell_type": "code",
1239
+ "execution_count": 33,
1240
+ "metadata": {
1241
+ "collapsed": false
1242
+ },
1243
+ "outputs": [
1244
+ {
1245
+ "data": {
1246
+ "text/html": [
1247
+ "<div id='vis-ee6e186c-7412-4aa0-a06f-a5c385f4e2ba'></div>\n",
1248
+ "<script>\n",
1249
+ "(function(){\n",
1250
+ " var render = function(){\n",
1251
+ " 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",
1252
+ " var id_name = '#vis-ee6e186c-7412-4aa0-a06f-a5c385f4e2ba';\n",
1253
+ " Nyaplot.core.parse(model, id_name);\n",
1254
+ "\n",
1255
+ " require(['downloadable'], function(downloadable){\n",
1256
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1257
+ "\t if(!svg.empty())\n",
1258
+ "\t svg.call(downloadable().filename('fig'));\n",
1259
+ "\t});\n",
1260
+ " };\n",
1261
+ " if(window['Nyaplot']==undefined){\n",
1262
+ " window.addEventListener('load_nyaplot', render, false);\n",
1263
+ "\treturn;\n",
1264
+ " } else {\n",
1265
+ " render();\n",
1266
+ " }\n",
1267
+ "})();\n",
1268
+ "</script>\n"
1269
+ ],
1270
+ "text/plain": [
1271
+ "#<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=>[]}>"
1272
+ ]
1273
+ },
1274
+ "metadata": {},
1275
+ "output_type": "display_data"
1276
+ }
1277
+ ],
1278
+ "source": [
1279
+ "line_1 = Daru::View::Plot.new(df, type: :line, x: :a, y: :b, categorized: {by: :c, method: :color})\n",
1280
+ "line_1.show_in_iruby"
1281
+ ]
1282
+ },
1283
+ {
1284
+ "cell_type": "code",
1285
+ "execution_count": 34,
1286
+ "metadata": {
1287
+ "collapsed": false
1288
+ },
1289
+ "outputs": [
1290
+ {
1291
+ "data": {
1292
+ "text/html": [
1293
+ "<div id='vis-bfe48f50-2780-41f1-8d72-609ab167eb26'></div>\n",
1294
+ "<script>\n",
1295
+ "(function(){\n",
1296
+ " var render = function(){\n",
1297
+ " 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",
1298
+ " var id_name = '#vis-bfe48f50-2780-41f1-8d72-609ab167eb26';\n",
1299
+ " Nyaplot.core.parse(model, id_name);\n",
1300
+ "\n",
1301
+ " require(['downloadable'], function(downloadable){\n",
1302
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1303
+ "\t if(!svg.empty())\n",
1304
+ "\t svg.call(downloadable().filename('fig'));\n",
1305
+ "\t});\n",
1306
+ " };\n",
1307
+ " if(window['Nyaplot']==undefined){\n",
1308
+ " window.addEventListener('load_nyaplot', render, false);\n",
1309
+ "\treturn;\n",
1310
+ " } else {\n",
1311
+ " render();\n",
1312
+ " }\n",
1313
+ "})();\n",
1314
+ "</script>\n"
1315
+ ],
1316
+ "text/plain": [
1317
+ "#<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=>[]}>"
1318
+ ]
1319
+ },
1320
+ "metadata": {},
1321
+ "output_type": "display_data"
1322
+ },
1323
+ {
1324
+ "data": {
1325
+ "text/html": [
1326
+ "<div id='vis-12367786-a326-4f34-866f-84391cf29311'></div>\n",
1327
+ "<script>\n",
1328
+ "(function(){\n",
1329
+ " var render = function(){\n",
1330
+ " 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",
1331
+ " var id_name = '#vis-12367786-a326-4f34-866f-84391cf29311';\n",
1332
+ " Nyaplot.core.parse(model, id_name);\n",
1333
+ "\n",
1334
+ " require(['downloadable'], function(downloadable){\n",
1335
+ " var svg = d3.select(id_name).select(\"svg\");\n",
1336
+ "\t if(!svg.empty())\n",
1337
+ "\t svg.call(downloadable().filename('fig'));\n",
1338
+ "\t});\n",
1339
+ " };\n",
1340
+ " if(window['Nyaplot']==undefined){\n",
1341
+ " window.addEventListener('load_nyaplot', render, false);\n",
1342
+ "\treturn;\n",
1343
+ " } else {\n",
1344
+ " render();\n",
1345
+ " }\n",
1346
+ "})();\n",
1347
+ "</script>\n"
1348
+ ],
1349
+ "text/plain": [
1350
+ "#<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]}}>"
1351
+ ]
1352
+ },
1353
+ "execution_count": 34,
1354
+ "metadata": {},
1355
+ "output_type": "execute_result"
1356
+ }
1357
+ ],
1358
+ "source": [
1359
+ "line_2 = Daru::View::Plot.new(df, type: :line, x: :a, y: :b, categorized: {by: :c, method: :stroke_width})\n",
1360
+ "line_2.show_in_iruby\n",
1361
+ "line_2.chart.xrange [-10, 10]\n",
1362
+ "line_2.chart.yrange [-10, 10]"
1363
+ ]
1364
+ },
1365
+ {
1366
+ "cell_type": "code",
1367
+ "execution_count": null,
1368
+ "metadata": {
1369
+ "collapsed": true
1370
+ },
1371
+ "outputs": [],
1372
+ "source": []
1373
+ }
1374
+ ],
1375
+ "metadata": {
1376
+ "kernelspec": {
1377
+ "display_name": "Ruby 2.3.1",
1378
+ "language": "ruby",
1379
+ "name": "ruby"
1380
+ },
1381
+ "language_info": {
1382
+ "file_extension": ".rb",
1383
+ "mimetype": "application/x-ruby",
1384
+ "name": "ruby",
1385
+ "version": "2.3.1"
1386
+ }
1387
+ },
1388
+ "nbformat": 4,
1389
+ "nbformat_minor": 2
1390
+ }