forked from voila-dashboards/voila
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request voila-dashboards#223 from SylvainCorlay/fixup-docs
Fixup documentation images
- Loading branch information
Showing
2 changed files
with
153 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"This demo uses voila to render a notebook to a custom HTML page using gridstack.js for the layout of each output. In the cell metadata you can change the default cell with and height (in grid units between 1 and 12) by specifying.\n", | ||
" * `grid_row`\n", | ||
" * `grid_columns`" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"n = 200\n", | ||
"\n", | ||
"x = np.linspace(0.0, 10.0, n)\n", | ||
"y = np.cumsum(np.random.randn(n)*10).astype(int)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import ipywidgets as widgets" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"label_selected = widgets.Label(value=\"Selected: 0\")\n", | ||
"label_selected" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"grid_columns": 8, | ||
"grid_rows": 4 | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"from bqplot import pyplot as plt\n", | ||
"import bqplot\n", | ||
"\n", | ||
"fig = plt.figure( title='Histogram')\n", | ||
"np.random.seed(0)\n", | ||
"hist = plt.hist(y, bins=25)\n", | ||
"hist.scales['sample'].min = float(y.min())\n", | ||
"hist.scales['sample'].max = float(y.max())\n", | ||
"display(fig)\n", | ||
"fig.layout.width = 'auto'\n", | ||
"fig.layout.height = 'auto'\n", | ||
"fig.layout.min_height = '300px' # so it shows nicely in the notebook\n", | ||
"fig.layout.flex = '1'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"grid_columns": 12, | ||
"grid_rows": 6 | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"from bqplot import pyplot as plt\n", | ||
"import bqplot\n", | ||
"\n", | ||
"fig = plt.figure( title='Line Chart')\n", | ||
"np.random.seed(0)\n", | ||
"n = 200\n", | ||
"p = plt.plot(x, y)\n", | ||
"fig" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fig.layout.width = 'auto'\n", | ||
"fig.layout.height = 'auto'\n", | ||
"fig.layout.min_height = '300px' # so it shows nicely in the notebook\n", | ||
"fig.layout.flex = '1'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"brushintsel = bqplot.interacts.BrushIntervalSelector(scale=p.scales['x'])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def update_range(*args):\n", | ||
" label_selected.value = \"Selected range {}\".format(brushintsel.selected)\n", | ||
" mask = (x > brushintsel.selected[0]) & (x < brushintsel.selected[1])\n", | ||
" hist.sample = y[mask]\n", | ||
" \n", | ||
"brushintsel.observe(update_range, 'selected')\n", | ||
"fig.interaction = brushintsel" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"celltoolbar": "Edit Metadata", | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.6.4" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |