j1-template 2022.4.0 → 2022.4.3
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/layouts/content_generator_article_navigator.html +1 -1
- data/_includes/themes/j1/layouts/content_generator_blog_archive.html +1 -1
- data/_includes/themes/j1/layouts/content_generator_news_panel_posts.html +1 -1
- data/assets/themes/j1/adapter/js/nbinteract.js +21 -10
- data/assets/themes/j1/core/js/template.min.js.map +1 -1
- data/assets/themes/j1/modules/bokeh/README.md +380 -0
- data/assets/themes/j1/modules/bokeh/js/v2.4.3/bokeh.min.js +596 -0
- data/assets/themes/j1/modules/nbInteract/css/theme/uno/nbinteract-core.css +7 -0
- data/assets/themes/j1/modules/nbInteract/css/theme/uno/nbinteract-core.min.css +1 -1
- data/assets/themes/j1/modules/vega/js/vega/LICENSE +27 -0
- data/assets/themes/j1/modules/vega/js/vega/README.md +42 -0
- data/assets/themes/j1/modules/vega/js/vega/vega-core.js +34550 -0
- data/assets/themes/j1/modules/vega/js/vega/vega-core.min.js +2 -0
- data/assets/themes/j1/modules/vega/js/vega/vega-core.min.js.map +1 -0
- data/assets/themes/j1/modules/vega/js/vega/vega.js +49095 -0
- data/assets/themes/j1/modules/vega/js/vega/vega.min.js +2 -0
- data/assets/themes/j1/modules/vega/js/vega/vega.min.js.map +1 -0
- data/assets/themes/j1/modules/vega/js/vega-embed/LICENSE +27 -0
- data/assets/themes/j1/modules/vega/js/vega-embed/README.md +230 -0
- data/assets/themes/j1/modules/vega/js/vega-embed/vega-embed.js +6607 -0
- data/assets/themes/j1/modules/vega/js/vega-embed/vega-embed.js.map +1 -0
- data/assets/themes/j1/modules/vega/js/vega-embed/vega-embed.min.js +21 -0
- data/assets/themes/j1/modules/vega/js/vega-embed/vega-embed.min.js.map +1 -0
- data/assets/themes/j1/modules/vega/js/vega-lite/LICENSE +27 -0
- data/assets/themes/j1/modules/vega/js/vega-lite/README.md +21 -0
- data/assets/themes/j1/modules/vega/js/vega-lite/vega-lite-schema.json +30999 -0
- data/assets/themes/j1/modules/vega/js/vega-lite/vega-lite.js +24585 -0
- data/assets/themes/j1/modules/vega/js/vega-lite/vega-lite.js.map +1 -0
- data/assets/themes/j1/modules/vega/js/vega-lite/vega-lite.min.js +2 -0
- data/assets/themes/j1/modules/vega/js/vega-lite/vega-lite.min.js.map +1 -0
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/Gemfile +1 -1
- data/lib/starter_web/_config.yml +1 -1
- data/lib/starter_web/_data/modules/defaults/nbinteract.yml +5 -1
- data/lib/starter_web/_data/modules/navigator_menu.yml +60 -56
- data/lib/starter_web/_data/modules/nbinteract.yml +83 -87
- data/lib/starter_web/_data/resources.yml +101 -0
- data/lib/starter_web/_plugins/lunr_index.rb +1 -1
- data/lib/starter_web/assets/images/modules/attics/shubham-dhage-2-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/wrongtog-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/yellow-cactus-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/icons/bokeh/bokeh-32x32.ico +0 -0
- data/lib/starter_web/assets/images/modules/icons/bokeh/bokeh.ico +0 -0
- data/lib/starter_web/assets/images/modules/icons/bokeh/logo-160x160.png +0 -0
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/public/jupyter/examples/{j1-circular-times-table.adoc → distributed/j1-circular-times-table.adoc} +7 -2
- data/lib/starter_web/pages/public/jupyter/examples/{j1-interactive-widgets.adoc → distributed/j1-common-used-widgets.adoc} +14 -6
- data/lib/starter_web/pages/public/jupyter/examples/{j1-odes-in-python.adoc → distributed/j1-odes-in-python.adoc} +7 -2
- data/lib/starter_web/pages/public/jupyter/examples/{j1_climate-change-forecast.adoc → localized/j1_climate-change-forecast.adoc} +10 -5
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_altair_interactive.html +2216 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_altair_non_interactive.html +1170 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_bokeh_01_basic_plotting.html +1479 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_bokeh_02_styling_and_theming.html +1524 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_bokeh_03_data_sources_and_transformations.html +983 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_bokeh_04_adding_annotations.html +1280 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_bokeh_05_presentation_layouts.html +660 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_bokeh_06_linking_and_interactions.html +1563 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_bokeh_07_bar_and_categorical_data_plots.html +1888 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_bokeh_08_graph_and_network_plots.html +689 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_bokeh_09_geographic_plots.html +767 -0
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_circular_times_table.html +2 -1
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/j1_interactive_widgets.html +21 -0
- data/lib/starter_web/pages/public/jupyter/where_to_go.adoc +239 -0
- data/lib/starter_web/pages/public/learn/where_to_go.adoc +23 -7
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +47 -42
- data/lib/starter_web/pages/public/jupyter/docs/_includes/attributes.asciidoc +0 -58
- data/lib/starter_web/pages/public/jupyter/docs/_includes/documents/j1_docs_example_static.asciidoc +0 -232
- data/lib/starter_web/pages/public/jupyter/docs/j1-nbinteract-doc.adoc +0 -563
- data/lib/starter_web/pages/public/jupyter/docs/nbi-widget-manual.adoc +0 -465
- data/lib/starter_web/pages/public/jupyter/docs/nbinteract-doc.adoc +0 -473
- data/lib/starter_web/pages/public/jupyter/examples/j1-testing-plotly.adoc +0 -94
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_circular_times_table-checkpoint.ipynb +0 -12387
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_climate_change_forecast-checkpoint.ipynb +0 -1058
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_docs_example_dynamic-checkpoint.ipynb +0 -14478
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_interactive_widgets-checkpoint.ipynb +0 -738
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_ode_selected-checkpoint.ipynb +0 -14478
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/.ipynb_checkpoints/j1_odes_in_python-checkpoint.ipynb +0 -15227
- data/lib/starter_web/pages/public/jupyter/notebooks/j1/factor_by_factor.mp4 +0 -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 +0 -247
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_examples_variability_of_the_sample_mean-checkpoint.ipynb +0 -323
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_graphing-checkpoint.ipynb +0 -387
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_interactive_questions-checkpoint.ipynb +0 -185
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_recipes_layout-checkpoint.ipynb +0 -384
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_tutorial_interact-checkpoint.ipynb +0 -254
- data/lib/starter_web/pages/public/jupyter/notebooks/nbi-docs/.ipynb_checkpoints/nbi_docs_tutorial_monty_hall-checkpoint.ipynb +0 -732
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_examples_central_limit_theorem.html +0 -290
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_examples_correlation.html +0 -818
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_examples_empirical_distributions.html +0 -351
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_examples_linear_regression.html +0 -106
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_examples_probability_distribution_plots.html +0 -228
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_examples_sampling_from_a_population.html +0 -518
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_examples_variability_of_the_sample_mean.html +0 -372
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_recipes_graphing.html +0 -473
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_recipes_interactive_questions.html +0 -242
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_recipes_layout.html +0 -496
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_tutorial_interact.html +0 -329
- data/lib/starter_web/pages/public/jupyter/notebooks/textbooks/nbi_docs_tutorial_monty_hall.html +0 -866
- data/lib/starter_web/pages/public/jupyter/services/binderhub.adoc +0 -564
- data/lib/starter_web/pages/public/jupyter/services/jupyterhub.adoc +0 -244
@@ -1,465 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: J1 NBI
|
3
|
-
tagline: nbinteract widgets
|
4
|
-
date: 2022-03-28 00:00:00
|
5
|
-
description: >
|
6
|
-
The package nbinteract aims to enable authors and educators to create and
|
7
|
-
share interactive web pages easily. Interactive explanations of concepts are
|
8
|
-
useful for communicating and explaining tricky concepts.
|
9
|
-
keywords: >
|
10
|
-
opensource, free, load, download, start, starter, example,
|
11
|
-
high, easy, use, secure, encrypt, standard, popular,
|
12
|
-
generate, create, learn, distribute, publish, deploy,
|
13
|
-
beginner, advanced, expert, student, learner, writer, reader, visitor
|
14
|
-
framework, toolkit, integration, extension, module, api,
|
15
|
-
dynamic, static, generator, client, server, internet, local, localhost
|
16
|
-
page, web, website, webdesign, material, design, responsive,
|
17
|
-
javascript, nodejs, ruby, windows, linux, osx, mac, os,
|
18
|
-
http, https, html, html5, css, scss, style,
|
19
|
-
browser, firefox, chrome, edge, opera, safari,
|
20
|
-
configuration, generator, navigation, menu, dropdown, fab, action, button
|
21
|
-
application, interface, provider, api, repository,
|
22
|
-
cookie, language, translation, gdpr, dsgvo, privacy,
|
23
|
-
asciidoc, aciidoctor, bootstrap, jekyll, liquid,
|
24
|
-
hyvor, disqus, git, github, netlify, heroku, apple, microsoft,
|
25
|
-
provider, service, internet, support,
|
26
|
-
google, analytics, advertising, search, console, silverlight, score,
|
27
|
-
j1, template, jekyllone, comment,
|
28
|
-
python, jupyter, notebook, textbook, api, app, nbinteract,
|
29
|
-
nbi, integration, binder, binderhub, jupyterhub
|
30
|
-
|
31
|
-
categories: [ Software, Python ]
|
32
|
-
tags: [ Binder, API ]
|
33
|
-
|
34
|
-
scrollbar: false
|
35
|
-
|
36
|
-
permalink: /pages/public/jupyter/docs/nbi-widgets/
|
37
|
-
regenerate: false
|
38
|
-
|
39
|
-
resources: [ animate, clipboard, lightbox, rouge ]
|
40
|
-
resource_options:
|
41
|
-
- attic:
|
42
|
-
padding_top: 400
|
43
|
-
padding_bottom: 50
|
44
|
-
opacity: 0.5
|
45
|
-
slides:
|
46
|
-
- url: /assets/images/modules/attics/runner-1920x1200.jpg
|
47
|
-
---
|
48
|
-
|
49
|
-
// Page Initializer
|
50
|
-
// =============================================================================
|
51
|
-
// Enable the Liquid Preprocessor
|
52
|
-
:page-liquid:
|
53
|
-
|
54
|
-
// Set (local) page attributes here
|
55
|
-
// -----------------------------------------------------------------------------
|
56
|
-
// :page--attr: <attr-value>
|
57
|
-
:badges-enabled: false
|
58
|
-
:binder-badge-enabled: false
|
59
|
-
:binder--home: https://mybinder.org/
|
60
|
-
:binder--docs: https://mybinder.readthedocs.io/en/latest/
|
61
|
-
:binder-app-launch--tree: https://mybinder.org/v2/gh/jekyll-one/j1-binder-repo/main?urlpath=/tree
|
62
|
-
|
63
|
-
// Load Liquid procedures
|
64
|
-
// -----------------------------------------------------------------------------
|
65
|
-
{% capture load_attributes %}themes/{{site.template.name}}/procedures/global/attributes_loader.proc{%endcapture%}
|
66
|
-
|
67
|
-
// Load page attributes
|
68
|
-
// -----------------------------------------------------------------------------
|
69
|
-
{% include {{load_attributes}} scope="global" %}
|
70
|
-
|
71
|
-
|
72
|
-
// Page content
|
73
|
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
74
|
-
ifeval::[{binder-badge-enabled} == true]
|
75
|
-
image:/assets/images/badges/myBinder.png[[Binder, link="{binder--home}", {browser-window--new}]
|
76
|
-
image:/assets/images/badges/docsBinder.png[[Binder, link="{binder--docs}", {browser-window--new}]
|
77
|
-
endif::[]
|
78
|
-
|
79
|
-
// Include sub-documents (if any)
|
80
|
-
// -----------------------------------------------------------------------------
|
81
|
-
|
82
|
-
The library *nbinteract* comes with a set of functions that produce
|
83
|
-
Javascript-based plots designed for interaction. The package combines the
|
84
|
-
_ipywidgets_ library and the _bqplot_ plotting library to implement
|
85
|
-
function-driven interfaces to interactive plotting.
|
86
|
-
|
87
|
-
The nbinteract plotting methods use _ipywidgets_ to generate and display
|
88
|
-
widgets, inferring the widget type as needed. When a user interacts with a
|
89
|
-
widget, a Python callback updates the visualization *without* a complete
|
90
|
-
rerender. This noticeably lowers visualization update time compared to using
|
91
|
-
ipywidgets alone to render static images.
|
92
|
-
|
93
|
-
== Histogram
|
94
|
-
|
95
|
-
The widget `nbinteract.hist` generates an interactive histogram that allows users to change the
|
96
|
-
parameters of the input hist_function.
|
97
|
-
|
98
|
-
[source, python, role="noclip"]
|
99
|
-
----
|
100
|
-
hist_function (Array | (*args -> Array int | Array float)):
|
101
|
-
Function that takes in parameters to interact with and returns an
|
102
|
-
array of numbers. These numbers will be plotted in the resulting
|
103
|
-
histogram.
|
104
|
-
----
|
105
|
-
|
106
|
-
.Example
|
107
|
-
[source, python, role="noclip"]
|
108
|
-
----
|
109
|
-
import nbinteract as nbi
|
110
|
-
import numpy as np
|
111
|
-
|
112
|
-
def hist_response_function(mean, sd, size=1000):
|
113
|
-
'''
|
114
|
-
Returns 1000 values picked at random from the normal
|
115
|
-
distribution with the mean and SD given.
|
116
|
-
'''
|
117
|
-
return np.random.normal(loc=mean, scale=sd, size=1000)
|
118
|
-
|
119
|
-
nbi.hist(hist_response_function, mean=(0, 10), sd=(0, 2.0, 0.2))
|
120
|
-
----
|
121
|
-
|
122
|
-
.Rendered Histogram
|
123
|
-
lightbox::nbi-widget--hist[800, {data-nbi-widget--hist}, role="mt-3 mb-4"]
|
124
|
-
|
125
|
-
=== Options
|
126
|
-
|
127
|
-
[source, python, role="noclip"]
|
128
|
-
----
|
129
|
-
options (dict): Options for the plot. Available options:
|
130
|
-
|
131
|
-
title: Title of the plot
|
132
|
-
aspect_ratio: Aspect ratio of plot figure (float)
|
133
|
-
animation_duration: Duration of transition on change of data, in milliseconds.
|
134
|
-
xlabel: Label of the x-axis
|
135
|
-
ylabel: Label of the y-axis
|
136
|
-
xlim: Tuple containing (lower, upper) for x-axis
|
137
|
-
ylim: Tuple containing (lower, upper) for y-axis
|
138
|
-
bins: Non-negative int for the number of bins (default 10)
|
139
|
-
normalized: Normalize histogram area to 1 if True. If False, plot unmodified counts. (default True)
|
140
|
-
|
141
|
-
interact_params (dict): Keyword arguments in the same format as
|
142
|
-
`ipywidgets.interact`. One argument is required for each argument
|
143
|
-
of `hist_function`.
|
144
|
-
----
|
145
|
-
|
146
|
-
== Bar chart
|
147
|
-
|
148
|
-
The widget `nbinteract.bar` generates an interactive bar chart that allows
|
149
|
-
users to change the parameters of the inputs x_fn and y_fn.
|
150
|
-
|
151
|
-
[source, python, role="noclip"]
|
152
|
-
----
|
153
|
-
x_fn (Array | (*args -> Array str | Array int | Array float)):
|
154
|
-
If array, uses array values for categories of bar chart.
|
155
|
-
|
156
|
-
If function, must take parameters to interact with and return an
|
157
|
-
array of strings or numbers. These will become the categories on
|
158
|
-
the x-axis of the bar chart.
|
159
|
-
|
160
|
-
y_fn (Array | (Array, *args -> Array int | Array float)):
|
161
|
-
If array, uses array values for heights of bars.
|
162
|
-
|
163
|
-
If function, must take in the output of x_fn as its first parameter
|
164
|
-
and optionally other parameters to interact with. Must return an
|
165
|
-
array of numbers. These will become the heights of the bars on the
|
166
|
-
y-axis.
|
167
|
-
----
|
168
|
-
|
169
|
-
.Example
|
170
|
-
[source, python, role="noclip"]
|
171
|
-
----
|
172
|
-
import nbinteract as nbi
|
173
|
-
import numpy as np
|
174
|
-
|
175
|
-
def categories(n):
|
176
|
-
return np.arange(n)
|
177
|
-
|
178
|
-
def heights(xs, offset):
|
179
|
-
return xs + offset
|
180
|
-
|
181
|
-
opts = {
|
182
|
-
'ylim': (0, 20),
|
183
|
-
}
|
184
|
-
|
185
|
-
nbi.bar(categories, heights, n=(0, 10), offset=(1, 10), options=opts)
|
186
|
-
----
|
187
|
-
|
188
|
-
.Rendered Barchart
|
189
|
-
lightbox::nbi-widget--bar[800, {data-nbi-widget--bar}, role="mt-3 mb-4"]
|
190
|
-
|
191
|
-
=== Options
|
192
|
-
|
193
|
-
[source, python, role="noclip"]
|
194
|
-
----
|
195
|
-
options (dict): Options for the plot. Available options:
|
196
|
-
|
197
|
-
title: Title of the plot
|
198
|
-
aspect_ratio: Aspect ratio of plot figure (float)
|
199
|
-
animation_duration: Duration of transition on change of data, in milliseconds.
|
200
|
-
xlabel: Label of the x-axis
|
201
|
-
ylabel: Label of the y-axis
|
202
|
-
ylim: Tuple containing (lower, upper) for y-axis
|
203
|
-
|
204
|
-
interact_params (dict): Keyword arguments in the same format as
|
205
|
-
`ipywidgets.interact`. One argument is required for each argument
|
206
|
-
of both `x_fn` and `y_fn`. If `x_fn` and `y_fn` have conflicting
|
207
|
-
parameter names, prefix the corresponding kwargs with `x__` and
|
208
|
-
`y__`.
|
209
|
-
----
|
210
|
-
|
211
|
-
|
212
|
-
== Interactive Scatter plot
|
213
|
-
|
214
|
-
The widget `nbinteract.scatter_drag` generates an interactive scatter plot
|
215
|
-
with the best fit line plotted over the points. The points can be dragged by
|
216
|
-
the user and the line will automatically update.
|
217
|
-
|
218
|
-
[source, python, role="noclip"]
|
219
|
-
----
|
220
|
-
x_points (Array Number): x-values of points to plot
|
221
|
-
y_points (Array Number): y-values of points to plot
|
222
|
-
----
|
223
|
-
|
224
|
-
.Example
|
225
|
-
[source, python, role="noclip"]
|
226
|
-
----
|
227
|
-
import nbinteract as nbi
|
228
|
-
import numpy as np
|
229
|
-
|
230
|
-
x_coords = np.arange(10)
|
231
|
-
y_coords = np.arange(10) + np.random.rand(10)
|
232
|
-
|
233
|
-
opts = {'xlim': (0, 9), 'ylim': (0, 11), 'animation_duration': 250}
|
234
|
-
|
235
|
-
nbi.scatter_drag(x_coords, y_coords, options=opts)
|
236
|
-
----
|
237
|
-
|
238
|
-
.Rendered interactive Scatter Plot
|
239
|
-
lightbox::nbi-widget--scatter-drag[800, {data-nbi-widget--scatter-drag}, role="mt-3 mb-4"]
|
240
|
-
|
241
|
-
=== Options
|
242
|
-
|
243
|
-
[source, python, role="noclip"]
|
244
|
-
----
|
245
|
-
show_eqn (bool): If True (default), displays the best fit line's
|
246
|
-
equation above the scatterplot.
|
247
|
-
|
248
|
-
options (dict): Options for the plot. Available options:
|
249
|
-
|
250
|
-
title: Title of the plot
|
251
|
-
aspect_ratio: Aspect ratio of plot figure (float)
|
252
|
-
animation_duration: Duration of transition on change of data, in milliseconds.
|
253
|
-
xlabel: Label of the x-axis
|
254
|
-
ylabel: Label of the y-axis
|
255
|
-
xlim: Tuple containing (lower, upper) for x-axis
|
256
|
-
ylim: Tuple containing (lower, upper) for y-axis
|
257
|
-
----
|
258
|
-
|
259
|
-
== Scatter
|
260
|
-
|
261
|
-
The widget `nbinteract.scatter` generates an interactive scatter chart that
|
262
|
-
allows users to change the parameters of the inputs x_fn and y_fn.
|
263
|
-
|
264
|
-
[source, python, role="noclip"]
|
265
|
-
----
|
266
|
-
x_fn (Array | (*args -> Array str | Array int | Array float)):
|
267
|
-
If array, uses array values for x-coordinates.
|
268
|
-
|
269
|
-
If function, must take parameters to interact with and return an
|
270
|
-
array of strings or numbers. These will become the x-coordinates
|
271
|
-
of the scatter plot.
|
272
|
-
|
273
|
-
y_fn (Array | (Array, *args -> Array int | Array float)):
|
274
|
-
If array, uses array values for y-coordinates.
|
275
|
-
|
276
|
-
If function, must take in the output of x_fn as its first parameter
|
277
|
-
and optionally other parameters to interact with. Must return an
|
278
|
-
array of numbers. These will become the y-coordinates of the
|
279
|
-
scatter plot.
|
280
|
-
----
|
281
|
-
|
282
|
-
.Example
|
283
|
-
[source, python, role="noclip"]
|
284
|
-
----
|
285
|
-
import nbinteract as nbi
|
286
|
-
import numpy as np
|
287
|
-
|
288
|
-
def x_values(n): return np.random.choice(100, n)
|
289
|
-
def y_values(xs): return np.random.choice(100, len(xs))
|
290
|
-
|
291
|
-
nbi.scatter(x_values, y_values, n=(0,200))
|
292
|
-
----
|
293
|
-
|
294
|
-
.Rendered Scatter Plot
|
295
|
-
lightbox::nbi-widget--scatter[800, {data-nbi-widget--scatter}, role="mt-3 mb-4"]
|
296
|
-
|
297
|
-
=== Options
|
298
|
-
|
299
|
-
[source, python, role="noclip"]
|
300
|
-
----
|
301
|
-
options (dict): Options for the plot. Available options:
|
302
|
-
|
303
|
-
title: Title of the plot
|
304
|
-
aspect_ratio: Aspect ratio of plot figure (float)
|
305
|
-
animation_duration: Duration of transition on change of data, in milliseconds.
|
306
|
-
xlabel: Label of the x-axis
|
307
|
-
ylabel: Label of the y-axis
|
308
|
-
xlim: Tuple containing (lower, upper) for x-axis
|
309
|
-
ylim: Tuple containing (lower, upper) for y-axis
|
310
|
-
marker: Shape of marker plots.
|
311
|
-
Possible values:
|
312
|
-
{"circle", "cross", "diamond", "square", "triangle-down", "triangle-up", "arrow", "rectangle", "ellipse"}
|
313
|
-
|
314
|
-
interact_params (dict): Keyword arguments in the same format as
|
315
|
-
`ipywidgets.interact`. One argument is required for each argument
|
316
|
-
of both `x_fn` and `y_fn`. If `x_fn` and `y_fn` have conflicting
|
317
|
-
parameter names, prefix the corresponding kwargs with `x__` and
|
318
|
-
`y__`.
|
319
|
-
----
|
320
|
-
|
321
|
-
== Line
|
322
|
-
|
323
|
-
Generates an interactive line chart that allows users to change the
|
324
|
-
parameters of the inputs `x_fn` and `y_fn`. The first two arguments of
|
325
|
-
`line` are *response functions* that return the x and y-axis coordinates.
|
326
|
-
|
327
|
-
Either argument can be *arrays* themselves. Arguments for the response
|
328
|
-
functions must be passed in as keyword arguments to line in the format
|
329
|
-
expected by interact. The response function for the y-coordinates will
|
330
|
-
be called with the x-coordinates as its first argument.
|
331
|
-
|
332
|
-
.Example
|
333
|
-
[source, python, role="noclip"]
|
334
|
-
----
|
335
|
-
import nbinteract as nbi
|
336
|
-
import numpy as np
|
337
|
-
|
338
|
-
def x_values(max): return np.arange(0, max)
|
339
|
-
def y_values(xs, sd):
|
340
|
-
return xs + np.random.normal(0, scale=sd, size=len(xs))
|
341
|
-
|
342
|
-
opts = {
|
343
|
-
'xlim': (0, 50),
|
344
|
-
'ylim': (0, 55),
|
345
|
-
'animation_duration': 250,
|
346
|
-
}
|
347
|
-
|
348
|
-
nbi.line(x_values, y_values, max=(10, 50), sd=(1, 10), options=opts)
|
349
|
-
----
|
350
|
-
|
351
|
-
.Rendered Line Plot
|
352
|
-
lightbox::nbi-widget--line[800, {data-nbi-widget--line}, role="mt-3 mb-4"]
|
353
|
-
|
354
|
-
[source, python, role="noclip"]
|
355
|
-
----
|
356
|
-
nbinteract.line(x_fn, y_fn, *, options={}, **interact_params)
|
357
|
-
|
358
|
-
x_fn (Array | (*args -> Array str | Array int | Array float)):
|
359
|
-
If array, uses array values for x-coordinates.
|
360
|
-
|
361
|
-
If function, must take parameters to interact with and return an
|
362
|
-
array of strings or numbers. These will become the x-coordinates
|
363
|
-
of the line plot.
|
364
|
-
|
365
|
-
y_fn (Array | (Array, *args -> Array int | Array float)):
|
366
|
-
If array, uses array values for y-coordinates.
|
367
|
-
|
368
|
-
If function, must take in the output of x_fn as its first parameter
|
369
|
-
and optionally other parameters to interact with. Must return an
|
370
|
-
array of numbers. These will become the y-coordinates of the line
|
371
|
-
plot.
|
372
|
-
----
|
373
|
-
|
374
|
-
=== Options
|
375
|
-
|
376
|
-
[source, python, role="noclip"]
|
377
|
-
----
|
378
|
-
options (dict): Options for the plot. Available options:
|
379
|
-
|
380
|
-
title: Title of the plot
|
381
|
-
aspect_ratio: Aspect ratio of plot figure (float)
|
382
|
-
animation_duration: Duration of transition on change of data, in milliseconds.
|
383
|
-
xlabel: Label of the x-axis
|
384
|
-
ylabel: Label of the y-axis
|
385
|
-
xlim: Tuple containing (lower, upper) for x-axis
|
386
|
-
ylim: Tuple containing (lower, upper) for y-axis
|
387
|
-
|
388
|
-
interact_params (dict): Keyword arguments in the same format as
|
389
|
-
`ipywidgets.interact`. One argument is required for each argument
|
390
|
-
of both `x_fn` and `y_fn`. If `x_fn` and `y_fn` have conflicting
|
391
|
-
parameter names, prefix the corresponding kwargs with `x__` and
|
392
|
-
`y__`.
|
393
|
-
----
|
394
|
-
|
395
|
-
== Multiple Choice
|
396
|
-
|
397
|
-
Generates a multiple choice question that allows the user to select an
|
398
|
-
answer choice and shows whether choice was correct.
|
399
|
-
|
400
|
-
[source, python, role="noclip"]
|
401
|
-
----
|
402
|
-
nbinteract.multiple_choice(question, choices, answers)
|
403
|
-
----
|
404
|
-
|
405
|
-
.Example
|
406
|
-
[source, python, role="noclip"]
|
407
|
-
----
|
408
|
-
import nbinteract as nbi
|
409
|
-
|
410
|
-
nbi.multiple_choice(question="Select all prime numbers.",
|
411
|
-
choices=['12', '3', '31'],
|
412
|
-
answers=[1, 2])
|
413
|
-
----
|
414
|
-
|
415
|
-
.Rendered Multiple Choice
|
416
|
-
lightbox::nbi-widget--multiple-choice[800, {data-nbi-widget--multiple-choice}, role="mt-3 mb-4"]
|
417
|
-
|
418
|
-
=== Options
|
419
|
-
|
420
|
-
[source, python, role="noclip"]
|
421
|
-
----
|
422
|
-
question (str): Question text displayed above choices.
|
423
|
-
|
424
|
-
choices (list str): Answer choices that user can select.
|
425
|
-
|
426
|
-
answers (int | iterable int): Either an integer or iterable of
|
427
|
-
integers. Each integer in answers corresponds to the index of the
|
428
|
-
correct choice in `choices`.
|
429
|
-
----
|
430
|
-
|
431
|
-
== Short Answer
|
432
|
-
|
433
|
-
Generates a short answer question that allows user to input an answer in
|
434
|
-
a textbox and a submit button to check the answer.
|
435
|
-
|
436
|
-
[source, python, role="noclip"]
|
437
|
-
----
|
438
|
-
nbinteract.short_answer(question, answers, explanation=None)
|
439
|
-
----
|
440
|
-
|
441
|
-
.Example
|
442
|
-
[source, python, role="noclip"]
|
443
|
-
----
|
444
|
-
import nbinteract as nbi
|
445
|
-
|
446
|
-
nbi.short_answer('What is 1+1?', answers='2', explanation='1+1 is 2')
|
447
|
-
----
|
448
|
-
|
449
|
-
.Rendered Short Answer
|
450
|
-
lightbox::nbi-widget--short-answer[800, {data-nbi-widget--short-answer}, role="mt-3 mb-4"]
|
451
|
-
|
452
|
-
=== Options
|
453
|
-
|
454
|
-
[source, python, role="noclip"]
|
455
|
-
----
|
456
|
-
question (str): The question being asked.
|
457
|
-
|
458
|
-
answers (str | list str | func): If a string, only that string will be
|
459
|
-
marked correct. If a list of string, any string in the list will be
|
460
|
-
marked correct. If a function, any input that causes the function
|
461
|
-
to return True will be marked correct.
|
462
|
-
|
463
|
-
explanation (str): The explanation to the question is displayed when
|
464
|
-
the user inputs the correct answer.
|
465
|
-
----
|