j1-template 2022.2.3 → 2022.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/themes/j1/modules/navigator/generator.html +1 -1
- data/assets/data/cookieconsent.html +4 -4
- data/assets/data/nbinteract.html +128 -0
- data/assets/data/quicklinks.html +15 -0
- data/assets/data/translator.html +15 -15
- data/assets/themes/j1/adapter/js/analytics.js +13 -13
- data/assets/themes/j1/adapter/js/cookieConsent.js +1 -1
- data/assets/themes/j1/adapter/js/mmenu.js +25 -3
- data/assets/themes/j1/adapter/js/navigator.js +2 -2
- data/assets/themes/j1/adapter/js/nbinteract.js +588 -146
- data/assets/themes/j1/core/css/themes/unodark/bootstrap.css +30 -40
- data/assets/themes/j1/core/css/themes/unodark/bootstrap.min.css +1 -1
- data/assets/themes/j1/core/css/themes/unolight/bootstrap.css +50 -66
- data/assets/themes/j1/core/css/themes/unolight/bootstrap.min.css +1 -1
- data/assets/themes/j1/core/js/template.js +15 -4
- data/assets/themes/j1/core/js/template.min.js +1 -1
- data/assets/themes/j1/core/js/template.min.js.map +1 -1
- data/assets/themes/j1/modules/carousel/css/theme/uno.css +5 -0
- data/assets/themes/j1/modules/carousel/css/theme/uno.min.css +1 -1
- data/assets/themes/j1/modules/cookieConsent/js/cookieConsent.js +1 -0
- data/assets/themes/j1/modules/justifiedGallery/css/justifiedGallery.css +6 -0
- data/assets/themes/j1/modules/justifiedGallery/css/justifiedGallery.min.css +1 -1
- data/assets/themes/j1/modules/mmenuLight/css/mmenu-light.css +2 -2
- data/assets/themes/j1/modules/mmenuLight/css/mmenu-light.min.css +1 -2
- data/assets/themes/j1/modules/nbInteract/css/theme/uno/nbinteract-core.css +33 -33
- data/assets/themes/j1/modules/nbInteract/css/theme/uno/nbinteract-core.min.css +1 -1
- data/assets/themes/j1/modules/nbInteract/js/nbinteract/nbinteract-core.js +1 -1
- data/assets/themes/j1/modules/nbInteract/js/nbinteract/nbinteract-core.js.map +1 -1
- data/assets/themes/j1/modules/nbInteract/js/nbinteract/nbinteract-core.min.js +1 -1
- data/assets/themes/j1/modules/nbInteract/js/requireJS/require.js +2068 -0
- data/assets/themes/j1/modules/nbInteract/js/requireJS/require.min.js +36 -0
- data/assets/themes/j1/modules/plotly/LICENSE +21 -0
- data/assets/themes/j1/modules/plotly/README.md +32 -0
- data/assets/themes/j1/modules/plotly/js/plotly.js +265345 -0
- data/assets/themes/j1/modules/plotly/js/plotly.min.js +65 -0
- data/assets/themes/j1/modules/requirejs/LICENSE +45 -0
- data/assets/themes/j1/modules/requirejs/README.md +79 -0
- data/assets/themes/j1/modules/requirejs/js/require.js +2068 -0
- data/assets/themes/j1/modules/requirejs/js/require.min.js +36 -0
- data/lib/j1/version.rb +3 -3
- data/lib/starter_web/Gemfile +1 -1
- data/lib/starter_web/_config.yml +1 -1
- data/lib/starter_web/_data/modules/analytics.yml +8 -23
- data/lib/starter_web/_data/modules/defaults/analytics.yml +1 -1
- data/lib/starter_web/_data/modules/defaults/cookieconsent.yml +55 -42
- data/lib/starter_web/_data/modules/defaults/navigator.yml +4 -0
- data/lib/starter_web/_data/modules/defaults/nbinteract.yml +95 -1
- data/lib/starter_web/_data/modules/defaults/translator.yml +24 -12
- data/lib/starter_web/_data/modules/justifiedGallery.yml +14 -8
- data/lib/starter_web/_data/modules/navigator_menu.yml +6 -3
- data/lib/starter_web/_data/modules/nbinteract.yml +12 -48
- data/lib/starter_web/_data/resources.yml +56 -0
- data/lib/starter_web/_includes/attributes.asciidoc +11 -0
- data/lib/starter_web/_plugins/lunr_index.rb +1 -1
- data/lib/starter_web/assets/images/pages/nbinteract/mandelbrot-menge-1920x1200.jpg +0 -0
- data/lib/starter_web/assets/images/pages/nbinteract/mandelbrot-menge.png +0 -0
- data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_bar.jpg +0 -0
- data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_hist.jpg +0 -0
- data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_line.jpg +0 -0
- data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_multiple_choice.jpg +0 -0
- data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_scatter.jpg +0 -0
- data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_scatter_drag.jpg +0 -0
- data/lib/starter_web/assets/images/pages/nbinteract/manual/nbi_short_answer.jpg +0 -0
- data/lib/starter_web/assets/videos/gallery/kick-it-old-school-poster.jpg +0 -0
- data/lib/starter_web/assets/videos/gallery/nye-party-shop-poster.jpg +0 -0
- data/lib/starter_web/assets/videos/gallery/stay-colorful-poster.jpg +0 -0
- data/lib/starter_web/collections/posts/public/series/_posts/2020-01-01-post-wiki-series.adoc +1 -0
- data/lib/starter_web/collections/posts/public/series/_posts/2020-01-02-post-wiki-series.adoc +1 -0
- data/lib/starter_web/collections/posts/public/series/_posts/2020-01-03-post-wiki-series.adoc +1 -0
- data/lib/starter_web/package.json +1 -2
- data/lib/starter_web/pages/public/jupyter/docs/j1-nbinteract-doc.adoc +34 -20
- data/lib/starter_web/pages/public/jupyter/docs/nbi-widget-manual.adoc +154 -7
- data/lib/starter_web/pages/public/jupyter/docs/nbinteract-doc.adoc +24 -19
- data/lib/starter_web/pages/public/jupyter/examples/j1-circular-times-table.adoc +135 -0
- data/lib/starter_web/pages/public/jupyter/examples/j1-interactive-widgets.adoc +8 -5
- data/lib/starter_web/pages/public/jupyter/examples/j1-odes-in-python.adoc +15 -7
- data/lib/starter_web/pages/public/jupyter/examples/j1-testing-plotly.adoc +94 -0
- data/lib/starter_web/pages/public/jupyter/examples/j1_climate-change-forecast.adoc +8 -8
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_circular_times_table-checkpoint.ipynb +12387 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_climate_change_forecast-checkpoint.ipynb +1058 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/{j1_ode_selected.ipynb → .ipynb_checkpoints/j1_docs_example_dynamic-checkpoint.ipynb} +1 -1
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_interactive_widgets-checkpoint.ipynb +26 -26
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/{j1_altair_interactive_test-checkpoint.ipynb → j1_ode_selected-checkpoint.ipynb} +99 -318
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_odes_in_python-checkpoint.ipynb +15227 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/factor_by_factor.mp4 +0 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/j1_circular_times_table.ipynb +12387 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/j1_climate_change_forecast.ipynb +2 -2
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/j1_docs_example_dynamic.ipynb +1 -1
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/j1_interactive_widgets.ipynb +26 -26
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/j1_odes_in_python.ipynb +15227 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/line_by_line.mp4 +0 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/point_by_point.mp4 +0 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_examples_central_limit_theorem-checkpoint.ipynb +247 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_examples_variability_of_the_sample_mean-checkpoint.ipynb +323 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_graphing-checkpoint.ipynb +387 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_layout-checkpoint.ipynb +384 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_tutorial_interact-checkpoint.ipynb +254 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_tutorial_monty_hall-checkpoint.ipynb +732 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/nbi_docs_examples_central_limit_theorem.ipynb +1 -2
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/nbi_docs_recipes_graphing.ipynb +18 -18
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/nbi_docs_tutorial_monty_hall.ipynb +25 -26
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_circular_times_table.html +746 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_climate_change_forecast.html +2 -2
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_docs_example_dynamic.html +186 -186
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_interactive_widgets.html +3 -3
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_odes_in_python.html +955 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_recipes_graphing.html +473 -473
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_recipes_interactive_questions.html +242 -242
- data/lib/starter_web/pages/public/jupyter/services/binderhub.adoc +3 -3
- data/lib/starter_web/pages/public/jupyter/services/jupyterhub.adoc +6 -7
- data/lib/starter_web/pages/public/learn/roundtrip/100_present_images.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/100_present_videos.adoc +9 -15
- data/lib/starter_web/pages/public/learn/roundtrip/200_typography.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/300_icon_fonts.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/410_bs_modals_extentions.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/420_responsive_tables_extensions.adoc +1 -1
- data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +117 -12
- data/lib/starter_web/pages/public/se/se-fake.adoc +47 -0
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +45 -22
- data/lib/starter_web/assets/videos/gallery/adriana-lima-poster.jpg +0 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/binder/binder-launches.ipynb +0 -385
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/Untitled-checkpoint.ipynb +0 -6
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/binder-launches-checkpoint.ipynb +0 -385
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/google_altair-checkpoint.ipynb +0 -33
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/binder-launches.ipynb +0 -411
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/binder-launches.html +0 -670
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_ode_selected.html +0 -186
- data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/excel.py +0 -55
- data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/ggplot.py +0 -108
- data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/ggplot2.py +0 -108
- data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/husky.py +0 -121
- data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/latimes.py +0 -149
- data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/pcolor.py +0 -6
- data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/quartz.py +0 -55
- data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/spacy_base.py +0 -94
- data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/spacy_mono.py +0 -158
- data/lib/starter_web/pages/public/jupyter/notebooks/themes/altair/sunsentinel.py +0 -125
@@ -0,0 +1,387 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "markdown",
|
5
|
+
"metadata": {},
|
6
|
+
"source": [
|
7
|
+
"### Plotting using `nbinteract`"
|
8
|
+
]
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"cell_type": "markdown",
|
12
|
+
"metadata": {},
|
13
|
+
"source": [
|
14
|
+
"`nbinteract` comes with a set of functions that produce Javascript-based plots designed for interaction.\n",
|
15
|
+
"\n",
|
16
|
+
"Most plotting functions that come with `nbinteract` take in response functions that return the **data** to be plotted."
|
17
|
+
]
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"cell_type": "code",
|
21
|
+
"execution_count": 1,
|
22
|
+
"metadata": {},
|
23
|
+
"outputs": [],
|
24
|
+
"source": [
|
25
|
+
"import nbinteract as nbi\n",
|
26
|
+
"import numpy as np"
|
27
|
+
]
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"cell_type": "markdown",
|
31
|
+
"metadata": {},
|
32
|
+
"source": [
|
33
|
+
"For a complete API reference for each function, you may type the function name in a cell and add a `?` at the end. For example, to view the API reference for `nbi.hist`:"
|
34
|
+
]
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"cell_type": "code",
|
38
|
+
"execution_count": 2,
|
39
|
+
"metadata": {},
|
40
|
+
"outputs": [],
|
41
|
+
"source": [
|
42
|
+
"nbi.hist?"
|
43
|
+
]
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"cell_type": "markdown",
|
47
|
+
"metadata": {},
|
48
|
+
"source": [
|
49
|
+
"#### `nbinteract.hist`"
|
50
|
+
]
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"cell_type": "markdown",
|
54
|
+
"metadata": {},
|
55
|
+
"source": [
|
56
|
+
"`hist` generates a histogram that allows interaction with the parameters for the response function. \n",
|
57
|
+
"\n",
|
58
|
+
"`hist` takes in a single response function. The response function returns the array of numerical values that will be shown in the histogram. The `hist` function allows interaction with the response function's parameters by specifying them as keyword arguments in the same format as `ipywidgets.interact`. Any argument that can be used for `ipywidgets.interact` can be used for `hist`."
|
59
|
+
]
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"cell_type": "code",
|
63
|
+
"execution_count": 3,
|
64
|
+
"metadata": {},
|
65
|
+
"outputs": [],
|
66
|
+
"source": [
|
67
|
+
"def hist_response_function(mean, sd, size=1000):\n",
|
68
|
+
" '''\n",
|
69
|
+
" Returns 1000 values picked at random from the normal\n",
|
70
|
+
" distribution with the mean and SD given.\n",
|
71
|
+
" '''\n",
|
72
|
+
" return np.random.normal(loc=mean, scale=sd, size=1000)"
|
73
|
+
]
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"cell_type": "code",
|
77
|
+
"execution_count": 13,
|
78
|
+
"metadata": {
|
79
|
+
"scrolled": false
|
80
|
+
},
|
81
|
+
"outputs": [
|
82
|
+
{
|
83
|
+
"data": {
|
84
|
+
"application/vnd.jupyter.widget-view+json": {
|
85
|
+
"model_id": "a5636ca1591943a39bbe131a1cf79eaa",
|
86
|
+
"version_major": 2,
|
87
|
+
"version_minor": 0
|
88
|
+
},
|
89
|
+
"text/plain": [
|
90
|
+
"VBox(children=(interactive(children=(IntSlider(value=5, description='mean', max=10), FloatSlider(value=1.0, de…"
|
91
|
+
]
|
92
|
+
},
|
93
|
+
"metadata": {},
|
94
|
+
"output_type": "display_data"
|
95
|
+
}
|
96
|
+
],
|
97
|
+
"source": [
|
98
|
+
"nbi.hist(hist_response_function, mean=(0, 10), sd=(0.2, 2.0, 0.2))"
|
99
|
+
]
|
100
|
+
},
|
101
|
+
{
|
102
|
+
"cell_type": "markdown",
|
103
|
+
"metadata": {},
|
104
|
+
"source": [
|
105
|
+
"If you interact with the above plot, you may notice that the plot's x and y-axes will automatically scale to match the input data. You can change plot parameters like the axes limits through the `options` parameter of the plotting functions:"
|
106
|
+
]
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"cell_type": "code",
|
110
|
+
"execution_count": 11,
|
111
|
+
"metadata": {},
|
112
|
+
"outputs": [
|
113
|
+
{
|
114
|
+
"data": {
|
115
|
+
"application/vnd.jupyter.widget-view+json": {
|
116
|
+
"model_id": "3b52fe08cd764b73bad8f2a92477d955",
|
117
|
+
"version_major": 2,
|
118
|
+
"version_minor": 0
|
119
|
+
},
|
120
|
+
"text/plain": [
|
121
|
+
"VBox(children=(interactive(children=(IntSlider(value=5, description='mean', max=10), FloatSlider(value=1.0, de…"
|
122
|
+
]
|
123
|
+
},
|
124
|
+
"metadata": {},
|
125
|
+
"output_type": "display_data"
|
126
|
+
}
|
127
|
+
],
|
128
|
+
"source": [
|
129
|
+
"options = {\n",
|
130
|
+
" 'title': '1000 random points from normal distribution',\n",
|
131
|
+
" 'xlim': (0, 15),\n",
|
132
|
+
" 'ylim': (0, 0.4),\n",
|
133
|
+
"}\n",
|
134
|
+
"nbi.hist(hist_response_function, options=options, mean=(0, 10), sd=(0.2, 2.0, 0.2))"
|
135
|
+
]
|
136
|
+
},
|
137
|
+
{
|
138
|
+
"cell_type": "markdown",
|
139
|
+
"metadata": {},
|
140
|
+
"source": [
|
141
|
+
"You may call `nbinteract` plotting functions with plain data as the input as well:"
|
142
|
+
]
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"cell_type": "code",
|
146
|
+
"execution_count": 6,
|
147
|
+
"metadata": {},
|
148
|
+
"outputs": [
|
149
|
+
{
|
150
|
+
"data": {
|
151
|
+
"application/vnd.jupyter.widget-view+json": {
|
152
|
+
"model_id": "f86ec97cd7ca493280a1815edd8f0ae9",
|
153
|
+
"version_major": 2,
|
154
|
+
"version_minor": 0
|
155
|
+
},
|
156
|
+
"text/plain": [
|
157
|
+
"VBox(children=(interactive(children=(Output(),), _dom_classes=('widget-interact',)), Figure(axes=[Axis(scale=L…"
|
158
|
+
]
|
159
|
+
},
|
160
|
+
"metadata": {},
|
161
|
+
"output_type": "display_data"
|
162
|
+
}
|
163
|
+
],
|
164
|
+
"source": [
|
165
|
+
"nbi.hist(np.random.normal(size=1000))"
|
166
|
+
]
|
167
|
+
},
|
168
|
+
{
|
169
|
+
"cell_type": "markdown",
|
170
|
+
"metadata": {},
|
171
|
+
"source": [
|
172
|
+
"#### `nbinteract.bar`"
|
173
|
+
]
|
174
|
+
},
|
175
|
+
{
|
176
|
+
"cell_type": "markdown",
|
177
|
+
"metadata": {},
|
178
|
+
"source": [
|
179
|
+
"`bar` generates an bar plot that allows interaction with the parameters for the response functions.\n",
|
180
|
+
"\n",
|
181
|
+
"The first two arguments of `bar` are response functions that return the x and y-axis data arrays, respectively. Either argument can be arrays themselves. Arguments for the response functions must be passed in as keyword arguments to `bar` in the format expected by interact. The response function for the y-axis data will be called with the x-axis data as its first argument.\n",
|
182
|
+
"\n",
|
183
|
+
"For example, in the bar plot below `categories` generates the categories to plot on the x-axis and `heights` generates the y-axis heights. The `heights` function uses the parameter `xs` which is the array of x-axis data points. "
|
184
|
+
]
|
185
|
+
},
|
186
|
+
{
|
187
|
+
"cell_type": "code",
|
188
|
+
"execution_count": 14,
|
189
|
+
"metadata": {},
|
190
|
+
"outputs": [
|
191
|
+
{
|
192
|
+
"data": {
|
193
|
+
"application/vnd.jupyter.widget-view+json": {
|
194
|
+
"model_id": "00316ec6767f4b879a61bef75599f78e",
|
195
|
+
"version_major": 2,
|
196
|
+
"version_minor": 0
|
197
|
+
},
|
198
|
+
"text/plain": [
|
199
|
+
"VBox(children=(interactive(children=(IntSlider(value=6, description='n', max=10, min=3), IntSlider(value=5, de…"
|
200
|
+
]
|
201
|
+
},
|
202
|
+
"metadata": {},
|
203
|
+
"output_type": "display_data"
|
204
|
+
}
|
205
|
+
],
|
206
|
+
"source": [
|
207
|
+
"def categories(n): \n",
|
208
|
+
" return np.arange(n)\n",
|
209
|
+
"\n",
|
210
|
+
"def heights(xs, offset):\n",
|
211
|
+
" return xs + offset\n",
|
212
|
+
"\n",
|
213
|
+
"opts = {\n",
|
214
|
+
" 'ylim': (0, 20),\n",
|
215
|
+
"}\n",
|
216
|
+
"\n",
|
217
|
+
"nbi.bar(categories, heights, n=(3, 10), offset=(1, 10), options=opts)"
|
218
|
+
]
|
219
|
+
},
|
220
|
+
{
|
221
|
+
"cell_type": "markdown",
|
222
|
+
"metadata": {},
|
223
|
+
"source": [
|
224
|
+
"#### `nbinteract.scatter_drag`"
|
225
|
+
]
|
226
|
+
},
|
227
|
+
{
|
228
|
+
"cell_type": "markdown",
|
229
|
+
"metadata": {},
|
230
|
+
"source": [
|
231
|
+
"`scatter_drag` generates a scatter plot that allows interaction through clicking and dragging the points on the graph. \n",
|
232
|
+
"\n",
|
233
|
+
"`scatter_drag` takes in two lists/arrays consisting of the x-coordinates and y-coordinates of the points to plot. It generates an interactive scatter plot where the points can be dragged by the user and a best fit line is updated automatically according to the placement of the points.\n",
|
234
|
+
"\n",
|
235
|
+
"`scatter_drag` does not allow response functions as inputs."
|
236
|
+
]
|
237
|
+
},
|
238
|
+
{
|
239
|
+
"cell_type": "code",
|
240
|
+
"execution_count": 8,
|
241
|
+
"metadata": {
|
242
|
+
"scrolled": false
|
243
|
+
},
|
244
|
+
"outputs": [
|
245
|
+
{
|
246
|
+
"data": {
|
247
|
+
"application/vnd.jupyter.widget-view+json": {
|
248
|
+
"model_id": "6b6494e0a17c4e2e8477509d44b1432e",
|
249
|
+
"version_major": 2,
|
250
|
+
"version_minor": 0
|
251
|
+
},
|
252
|
+
"text/plain": [
|
253
|
+
"VBox(children=(Label(value='y = 0.94x + 0.66'), Figure(animation_duration=250, axes=[Axis(scale=LinearScale(ma…"
|
254
|
+
]
|
255
|
+
},
|
256
|
+
"metadata": {},
|
257
|
+
"output_type": "display_data"
|
258
|
+
}
|
259
|
+
],
|
260
|
+
"source": [
|
261
|
+
"x_coords = np.arange(10)\n",
|
262
|
+
"y_coords = np.arange(10) + np.random.rand(10)\n",
|
263
|
+
"\n",
|
264
|
+
"opts = {'xlim': (0, 9), 'ylim': (0, 11), 'animation_duration': 250}\n",
|
265
|
+
"\n",
|
266
|
+
"nbi.scatter_drag(x_coords, y_coords, options=opts)"
|
267
|
+
]
|
268
|
+
},
|
269
|
+
{
|
270
|
+
"cell_type": "markdown",
|
271
|
+
"metadata": {},
|
272
|
+
"source": [
|
273
|
+
"#### `nbinteract.scatter`"
|
274
|
+
]
|
275
|
+
},
|
276
|
+
{
|
277
|
+
"cell_type": "markdown",
|
278
|
+
"metadata": {},
|
279
|
+
"source": [
|
280
|
+
"`scatter` generates a scatter plot that allows interaction with the parameters to the response functions. \n",
|
281
|
+
"This is different from scatter_drag which facilitates interaction using click and drag actions.\n",
|
282
|
+
"\n",
|
283
|
+
"The first two arguments of `scatter` are response functions that return the x and y-axis coordinates, respectively. Either argument can be arrays themselves. Arguments for the response functions must be passed in as keyword arguments to `scatter` in the format expected by interact. The response function for the y-coordinates will be called with the x-coordinates as its first argument."
|
284
|
+
]
|
285
|
+
},
|
286
|
+
{
|
287
|
+
"cell_type": "code",
|
288
|
+
"execution_count": 15,
|
289
|
+
"metadata": {
|
290
|
+
"scrolled": false
|
291
|
+
},
|
292
|
+
"outputs": [
|
293
|
+
{
|
294
|
+
"data": {
|
295
|
+
"application/vnd.jupyter.widget-view+json": {
|
296
|
+
"model_id": "847b13ca28274786b3209932e3a74f77",
|
297
|
+
"version_major": 2,
|
298
|
+
"version_minor": 0
|
299
|
+
},
|
300
|
+
"text/plain": [
|
301
|
+
"VBox(children=(interactive(children=(IntSlider(value=105, description='n', max=200, min=10), Output()), _dom_c…"
|
302
|
+
]
|
303
|
+
},
|
304
|
+
"metadata": {},
|
305
|
+
"output_type": "display_data"
|
306
|
+
}
|
307
|
+
],
|
308
|
+
"source": [
|
309
|
+
"def x_values(n): return np.random.choice(100, n)\n",
|
310
|
+
"def y_values(xs): return np.random.choice(100, len(xs))\n",
|
311
|
+
"\n",
|
312
|
+
"nbi.scatter(x_values, y_values, n=(10,200))"
|
313
|
+
]
|
314
|
+
},
|
315
|
+
{
|
316
|
+
"cell_type": "markdown",
|
317
|
+
"metadata": {},
|
318
|
+
"source": [
|
319
|
+
"#### `nbinteract.line`"
|
320
|
+
]
|
321
|
+
},
|
322
|
+
{
|
323
|
+
"cell_type": "markdown",
|
324
|
+
"metadata": {},
|
325
|
+
"source": [
|
326
|
+
"`line` generates a scatter plot that allows interaction with the parameters to the response functions. \n",
|
327
|
+
"\n",
|
328
|
+
"The first two arguments of `line` are response functions that return the x and y-axis coordinates, respectively. Either argument can be arrays themselves. Arguments for the response functions must be passed in as keyword arguments to `line` in the format expected by interact. The response function for the y-coordinates will be called with the x-coordinates as its first argument."
|
329
|
+
]
|
330
|
+
},
|
331
|
+
{
|
332
|
+
"cell_type": "code",
|
333
|
+
"execution_count": 10,
|
334
|
+
"metadata": {},
|
335
|
+
"outputs": [
|
336
|
+
{
|
337
|
+
"data": {
|
338
|
+
"application/vnd.jupyter.widget-view+json": {
|
339
|
+
"model_id": "b23113b7d9f54ca0844bc5874ca92137",
|
340
|
+
"version_major": 2,
|
341
|
+
"version_minor": 0
|
342
|
+
},
|
343
|
+
"text/plain": [
|
344
|
+
"VBox(children=(interactive(children=(IntSlider(value=30, description='max', max=50, min=10), IntSlider(value=5…"
|
345
|
+
]
|
346
|
+
},
|
347
|
+
"metadata": {},
|
348
|
+
"output_type": "display_data"
|
349
|
+
}
|
350
|
+
],
|
351
|
+
"source": [
|
352
|
+
"def x_values(max): return np.arange(0, max)\n",
|
353
|
+
"def y_values(xs, sd):\n",
|
354
|
+
" return xs + np.random.normal(0, scale=sd, size=len(xs))\n",
|
355
|
+
"\n",
|
356
|
+
"opts = {\n",
|
357
|
+
" 'xlim': (0, 50),\n",
|
358
|
+
" 'ylim': (0, 55),\n",
|
359
|
+
" 'animation_duration': 250,\n",
|
360
|
+
"}\n",
|
361
|
+
"\n",
|
362
|
+
"nbi.line(x_values, y_values, max=(10, 50), sd=(1, 10), options=opts)"
|
363
|
+
]
|
364
|
+
}
|
365
|
+
],
|
366
|
+
"metadata": {
|
367
|
+
"kernelspec": {
|
368
|
+
"display_name": "Python 3",
|
369
|
+
"language": "python",
|
370
|
+
"name": "python3"
|
371
|
+
},
|
372
|
+
"language_info": {
|
373
|
+
"codemirror_mode": {
|
374
|
+
"name": "ipython",
|
375
|
+
"version": 3
|
376
|
+
},
|
377
|
+
"file_extension": ".py",
|
378
|
+
"mimetype": "text/x-python",
|
379
|
+
"name": "python",
|
380
|
+
"nbconvert_exporter": "python",
|
381
|
+
"pygments_lexer": "ipython3",
|
382
|
+
"version": "3.7.9"
|
383
|
+
}
|
384
|
+
},
|
385
|
+
"nbformat": 4,
|
386
|
+
"nbformat_minor": 2
|
387
|
+
}
|