|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "code",
|
5 |
| - "execution_count": 5, |
| 5 | + "execution_count": null, |
6 | 6 | "metadata": {},
|
7 | 7 | "outputs": [],
|
8 | 8 | "source": [
|
|
19 | 19 | },
|
20 | 20 | {
|
21 | 21 | "cell_type": "code",
|
22 |
| - "execution_count": 6, |
| 22 | + "execution_count": null, |
23 | 23 | "metadata": {},
|
24 |
| - "outputs": [ |
25 |
| - { |
26 |
| - "data": { |
27 |
| - "application/javascript": [ |
28 |
| - "\n", |
29 |
| - "var s = document.createElement(\"style\");\n", |
30 |
| - "s.innerHTML = `\n", |
31 |
| - "path {\n", |
32 |
| - " stroke: #fff;\n", |
33 |
| - "}\n", |
34 |
| - "\n", |
35 |
| - "path:first-child {\n", |
36 |
| - " fill: yellow !important;\n", |
37 |
| - "}\n", |
38 |
| - "\n", |
39 |
| - "circle {\n", |
40 |
| - " fill: #000;\n", |
41 |
| - " pointer-events: none;\n", |
42 |
| - "}\n", |
43 |
| - "\n", |
44 |
| - ".q0-9 { fill: rgb(197,27,125); }\n", |
45 |
| - ".q1-9 { fill: rgb(222,119,174); }\n", |
46 |
| - ".q2-9 { fill: rgb(241,182,218); }\n", |
47 |
| - ".q3-9 { fill: rgb(253,224,239); }\n", |
48 |
| - ".q4-9 { fill: rgb(247,247,247); }\n", |
49 |
| - ".q5-9 { fill: rgb(230,245,208); }\n", |
50 |
| - ".q6-9 { fill: rgb(184,225,134); }\n", |
51 |
| - ".q7-9 { fill: rgb(127,188,65); }\n", |
52 |
| - ".q8-9 { fill: rgb(77,146,33); }`;\n", |
53 |
| - "\n", |
54 |
| - "document.getElementsByTagName(\"head\")[0].appendChild(s);\n" |
55 |
| - ], |
56 |
| - "text/plain": [ |
57 |
| - "<IPython.core.display.Javascript object>" |
58 |
| - ] |
59 |
| - }, |
60 |
| - "metadata": {}, |
61 |
| - "output_type": "display_data" |
62 |
| - } |
63 |
| - ], |
| 24 | + "outputs": [], |
64 | 25 | "source": [
|
65 | 26 | "%%javascript\n",
|
66 | 27 | "\n",
|
|
94 | 55 | },
|
95 | 56 | {
|
96 | 57 | "cell_type": "code",
|
97 |
| - "execution_count": 7, |
| 58 | + "execution_count": null, |
98 | 59 | "metadata": {},
|
99 | 60 | "outputs": [],
|
100 | 61 | "source": [
|
|
108 | 69 | },
|
109 | 70 | {
|
110 | 71 | "cell_type": "code",
|
111 |
| - "execution_count": 8, |
| 72 | + "execution_count": null, |
112 | 73 | "metadata": {},
|
113 |
| - "outputs": [ |
114 |
| - { |
115 |
| - "data": { |
116 |
| - "application/javascript": [ |
117 |
| - "require.undef('myd3');\n", |
118 |
| - "\n", |
119 |
| - "define('myd3', [\"@jupyter-widgets/base\",\n", |
120 |
| - " \"https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.js\"], function(widgets, d3) {\n", |
121 |
| - " \n", |
122 |
| - " var HelloView = widgets.DOMWidgetView.extend({\n", |
123 |
| - " \n", |
124 |
| - " render: function() { \n", |
125 |
| - " var that = this;\n", |
126 |
| - " this.width = this.model.get('width');\n", |
127 |
| - " this.height = this.model.get('height');\n", |
128 |
| - " that.vertices = this.model.get('vertices');\n", |
129 |
| - " \n", |
130 |
| - " that.voronoi = d3.geom.voronoi()\n", |
131 |
| - " .clipExtent([[0, 0], [that.width, that.height]]);\n", |
132 |
| - "\n", |
133 |
| - " this.svg = d3.select(this.el).append(\"svg\")\n", |
134 |
| - " .attr(\"width\", that.width)\n", |
135 |
| - " .attr(\"height\", that.height)\n", |
136 |
| - " .on(\"mousemove\", function() { \n", |
137 |
| - " that.vertices[0] = d3.mouse(this);\n", |
138 |
| - " that.redraw();\n", |
139 |
| - " });\n", |
140 |
| - " \n", |
141 |
| - " var g1 = this.svg.append(\"g\");\n", |
142 |
| - " this.path = g1.selectAll(\"path\");\n", |
143 |
| - " var g2 = this.svg.append(\"g\");\n", |
144 |
| - " this.circle = g2.selectAll(\"circle\");\n", |
145 |
| - "\n", |
146 |
| - " this.model.on('change:vertices', this.update_vertices, this);\n", |
147 |
| - " this.redraw();\n", |
148 |
| - " },\n", |
149 |
| - " \n", |
150 |
| - " update_vertices: function() {\n", |
151 |
| - " this.redraw();\n", |
152 |
| - " },\n", |
153 |
| - " \n", |
154 |
| - " redraw: function () {\n", |
155 |
| - " this.vertices = this.model.get('vertices');\n", |
156 |
| - "\n", |
157 |
| - " this.path = this.path\n", |
158 |
| - " .data(this.voronoi(this.vertices), this.polygon);\n", |
159 |
| - " this.path.exit().remove();\n", |
160 |
| - " this.path.enter().append(\"path\")\n", |
161 |
| - " .attr(\"class\", function(d, i) { return \"q\" + (i % 9) + \"-9\"; })\n", |
162 |
| - " .attr(\"d\", this.polygon);\n", |
163 |
| - " this.path.order();\n", |
164 |
| - "\n", |
165 |
| - " this.circle = this.circle\n", |
166 |
| - " .data([]);\n", |
167 |
| - " this.circle.exit().remove();\n", |
168 |
| - " \n", |
169 |
| - " this.circle = this.circle\n", |
170 |
| - " .data(this.vertices.slice(1)); \n", |
171 |
| - "\n", |
172 |
| - " this.circle.enter().append(\"circle\")\n", |
173 |
| - " .attr(\"transform\", function(d) { \n", |
174 |
| - " return \"translate(\" + d + \")\";\n", |
175 |
| - " })\n", |
176 |
| - " .attr(\"r\", 1.5);\n", |
177 |
| - " },\n", |
178 |
| - " \n", |
179 |
| - " polygon: function (d) {\n", |
180 |
| - " return \"M\" + d.join(\"L\") + \"Z\";\n", |
181 |
| - " }\n", |
182 |
| - " });\n", |
183 |
| - " \n", |
184 |
| - " return {\n", |
185 |
| - " HelloView : HelloView\n", |
186 |
| - " };\n", |
187 |
| - "});\n" |
188 |
| - ], |
189 |
| - "text/plain": [ |
190 |
| - "<IPython.core.display.Javascript object>" |
191 |
| - ] |
192 |
| - }, |
193 |
| - "metadata": {}, |
194 |
| - "output_type": "display_data" |
195 |
| - } |
196 |
| - ], |
| 74 | + "outputs": [], |
197 | 75 | "source": [
|
198 | 76 | "%%javascript\n",
|
199 | 77 | "require.undef('myd3');\n",
|
|
271 | 149 | },
|
272 | 150 | {
|
273 | 151 | "cell_type": "code",
|
274 |
| - "execution_count": 9, |
| 152 | + "execution_count": null, |
275 | 153 | "metadata": {},
|
276 |
| - "outputs": [ |
277 |
| - { |
278 |
| - "data": { |
279 |
| - "application/vnd.jupyter.widget-view+json": { |
280 |
| - "model_id": "085e2bc3e4ca4559b5e716000556498a", |
281 |
| - "version_major": 2, |
282 |
| - "version_minor": 0 |
283 |
| - }, |
284 |
| - "text/plain": [ |
285 |
| - "MyD3(height=300, vertices=[[381.19521593979994, 254.6699557324651], [528.3166463597643, 232.1950820743343], [3…" |
286 |
| - ] |
287 |
| - }, |
288 |
| - "metadata": {}, |
289 |
| - "output_type": "display_data" |
290 |
| - } |
291 |
| - ], |
| 154 | + "outputs": [], |
292 | 155 | "source": [
|
293 | 156 | "import numpy as np\n",
|
294 | 157 | "sample_size = 100\n",
|
|
302 | 165 | },
|
303 | 166 | {
|
304 | 167 | "cell_type": "code",
|
305 |
| - "execution_count": 20, |
| 168 | + "execution_count": null, |
306 | 169 | "metadata": {},
|
307 | 170 | "outputs": [],
|
308 | 171 | "source": [
|
|
349 | 212 | }
|
350 | 213 | },
|
351 | 214 | "nbformat": 4,
|
352 |
| - "nbformat_minor": 1 |
| 215 | + "nbformat_minor": 4 |
353 | 216 | }
|
0 commit comments