Skip to content

Commit aa1bce4

Browse files
authored
Various updates (#2)
* Tutorial dashboard and data -> notebook folder * Open links in new tab * Add and link TOC * Typos and small updates * Update color mapper section * Add red banner to highlight demo dashboard * Update ColorMappers * Fix typos
1 parent 3e3a019 commit aa1bce4

18 files changed

+1173
-486
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ This is helpful if you can't access mybinder.org, or if you want to
1414

1515
## Local setup
1616

17-
To run the tutorial locally, you first need to clone this repository to your local
18-
machine. For example:
17+
To run the tutorial locally, first clone this repository to your local machine.
18+
For example:
1919

2020
```bash
2121
git clone [email protected]:bokeh/tutorial.git

notebooks/01_introduction.ipynb

Lines changed: 28 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"<table style=\"float:left; border:none\">\n",
88
" <tr style=\"border:none\">\n",
99
" <td style=\"border:none\">\n",
10-
" <a href=\"https://bokeh.org/\">\n",
10+
" <a href=\"https://bokeh.org/\" target=\"_blank\">\n",
1111
" <img\n",
1212
" src=\"assets/bokeh-transparent.png\"\n",
1313
" style=\"width:50px\"\n",
@@ -20,17 +20,16 @@
2020
" </tr>\n",
2121
"</table>\n",
2222
"\n",
23-
"<div style=\"float:right;\"><h2>01 Tutorial Overview</h2></div>"
23+
"<div style=\"float:right;\"><a href=\"TOC.ipynb\" target=\"_blank\">Table of contents</a><br><h2>01 Tutorial Overview</h2></div>"
2424
]
2525
},
2626
{
27-
"attachments": {},
2827
"cell_type": "markdown",
2928
"metadata": {},
3029
"source": [
3130
"### What is Bokeh?\n",
3231
"\n",
33-
"Bokeh is an open source library for creating **interactive visualization for modern web\n",
32+
"Bokeh is an open-source library for creating **interactive visualization for modern web\n",
3433
"browsers**.\n",
3534
"\n",
3635
"With Bokeh, you can use Python to build beautiful data visualizations, ranging from\n",
@@ -67,55 +66,30 @@
6766
"source": [
6867
"# create a complex chart with mouse-over tooltips\n",
6968
"\n",
70-
"from bokeh.models import ColumnDataSource, HoverTool\n",
69+
"from bokeh.palettes import HighContrast3\n",
7170
"from bokeh.plotting import figure, show\n",
72-
"from bokeh.sampledata.autompg import autompg_clean as df\n",
73-
"from bokeh.transform import factor_cmap\n",
7471
"\n",
75-
"df.cyl = df.cyl.astype(str)\n",
76-
"df.yr = df.yr.astype(str)\n",
72+
"fruits = [\"Apples\", \"Pears\", \"Nectarines\", \"Plums\", \"Grapes\", \"Strawberries\"]\n",
73+
"years = [\"2015\", \"2016\", \"2017\"]\n",
74+
"\n",
75+
"data = {\"fruits\": fruits, \"2015\": [2, 1, 4, 3, 2, 4], \"2016\": [5, 3, 4, 2, 4, 6], \"2017\": [3, 2, 4, 4, 5, 3]}\n",
7776
"\n",
78-
"group = df.groupby(by=[\"cyl\", \"mfr\"])\n",
79-
"source = ColumnDataSource(group)\n",
77+
"p = figure(x_range=fruits, height=250, title=\"Fruit Counts by Year\", toolbar_location=None, tools=\"hover\", tooltips=\"$name @fruits: @$name\")\n",
8078
"\n",
81-
"p = figure(\n",
82-
" width=800,\n",
83-
" height=300,\n",
84-
" title=\"Mean MPG by # Cylinders and Manufacturer\",\n",
85-
" x_range=group,\n",
86-
" toolbar_location=None,\n",
87-
" tools=\"\",\n",
88-
")\n",
79+
"p.vbar_stack(years, x=\"fruits\", width=0.9, color=HighContrast3, source=data, legend_label=years)\n",
8980
"\n",
81+
"p.y_range.start = 0\n",
82+
"p.x_range.range_padding = 0.1\n",
9083
"p.xgrid.grid_line_color = None\n",
91-
"p.xaxis.axis_label = \"Manufacturer grouped by # Cylinders\"\n",
92-
"p.xaxis.major_label_orientation = 1.2\n",
93-
"\n",
94-
"index_cmap = factor_cmap(\n",
95-
" \"cyl_mfr\",\n",
96-
" palette=[\"#2b83ba\", \"#abdda4\", \"#ffffbf\", \"#fdae61\", \"#d7191c\"],\n",
97-
" factors=sorted(df.cyl.unique()),\n",
98-
" end=1,\n",
99-
")\n",
100-
"\n",
101-
"p.vbar(\n",
102-
" x=\"cyl_mfr\",\n",
103-
" top=\"mpg_mean\",\n",
104-
" width=1,\n",
105-
" source=source,\n",
106-
" line_color=\"white\",\n",
107-
" fill_color=index_cmap,\n",
108-
" hover_line_color=\"darkgrey\",\n",
109-
" hover_fill_color=index_cmap,\n",
110-
")\n",
111-
"\n",
112-
"p.add_tools(HoverTool(tooltips=[(\"MPG\", \"@mpg_mean\"), (\"Cyl, Mfr\", \"@cyl_mfr\")]))\n",
84+
"p.axis.minor_tick_line_color = None\n",
85+
"p.outline_line_color = None\n",
86+
"p.legend.location = \"top_left\"\n",
87+
"p.legend.orientation = \"horizontal\"\n",
11388
"\n",
11489
"show(p)"
11590
]
11691
},
11792
{
118-
"attachments": {},
11993
"cell_type": "markdown",
12094
"metadata": {},
12195
"source": [
@@ -130,7 +104,9 @@
130104
"[\"T-100 Domestic Market\"](https://transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FIL&QO_fu146_anzr=Nv4%20Pn44vr45)\n",
131105
"dataset of airline routes within the United States for the year 2021.\n",
132106
"\n",
133-
"Run the next code cell to see the dashboard you'll be building:"
107+
"<p style=\"background-color: #f74531; padding: 10px;\">\n",
108+
"👇 Run the code cell below to see the dashboard you'll be building:\n",
109+
"</p>"
134110
]
135111
},
136112
{
@@ -139,13 +115,9 @@
139115
"metadata": {},
140116
"outputs": [],
141117
"source": [
142-
"# load dashboard object\n",
143-
"import sys\n",
144-
"\n",
145-
"sys.path.append(\"../data\")\n",
118+
"# load and display tutorial dashboard\n",
146119
"from tutorial_dashboard import dashboard_layout\n",
147120
"\n",
148-
"# show dashboard\n",
149121
"show(dashboard_layout)"
150122
]
151123
},
@@ -154,7 +126,7 @@
154126
"cell_type": "markdown",
155127
"metadata": {},
156128
"source": [
157-
"This dashboard might take a few seconds to load. Once it is loaded, you can interact\n",
129+
"This dashboard **might take a few seconds to load**. Once it is loaded, you can interact\n",
158130
"with the different elements of the dashboard.\n",
159131
"\n",
160132
"The tutorial will walk you through all the steps of creating this dashboard, introducing\n",
@@ -179,11 +151,13 @@
179151
"* [11 Widgets and interactivity](11_widgets_interactivity.ipynb)\n",
180152
"* [12 Building the demo dashboard](12_demo_dashboard.ipynb)\n",
181153
"* [13 Exporting and embedding](13_exporting_embedding.ipynb)\n",
182-
"* [14 Next steps](15_next_steps.ipynb)"
154+
"* [14 Next steps](15_next_steps.ipynb)\n",
155+
"\n",
156+
"You can always access this table of contents using the link in the top right corner of\n",
157+
"every chapter!"
183158
]
184159
},
185160
{
186-
"attachments": {},
187161
"cell_type": "markdown",
188162
"metadata": {},
189163
"source": [
@@ -215,7 +189,6 @@
215189
]
216190
},
217191
{
218-
"attachments": {},
219192
"cell_type": "markdown",
220193
"metadata": {},
221194
"source": [
@@ -227,15 +200,10 @@
227200
"Run each code cell as you make your way through each chapter.\n",
228201
"\n",
229202
"Please **run the code cells in the order they are presented** in the notebooks. If you\n",
230-
"don't run the code cells in the correct order, you might get errors.\n",
231-
"\n",
232-
"Running code means you update the notebook file. When you close a notebook to move from\n",
233-
"one chapter to another, your browser will ask you for **confirmation to leave the site**.\n",
234-
"You can safely ignore this message for the purpose of this tutorial."
203+
"don't run the code cells in the correct order, you might get errors."
235204
]
236205
},
237206
{
238-
"attachments": {},
239207
"cell_type": "markdown",
240208
"metadata": {},
241209
"source": [
@@ -274,7 +242,6 @@
274242
]
275243
},
276244
{
277-
"attachments": {},
278245
"cell_type": "markdown",
279246
"metadata": {},
280247
"source": [
@@ -303,13 +270,12 @@
303270
]
304271
},
305272
{
306-
"attachments": {},
307273
"cell_type": "markdown",
308274
"metadata": {},
309275
"source": [
310276
"# Next section\n",
311277
"\n",
312-
"<a href=\"02_installation_and_setup.ipynb\">\n",
278+
"<a href=\"02_installation_and_setup.ipynb\" target=\"_blank\">\n",
313279
" <img src=\"assets/arrow.svg\" alt=\"Next section\" width=\"100\" align=\"right\">\n",
314280
"</a>\n",
315281
"\n",
@@ -322,7 +288,7 @@
322288
],
323289
"metadata": {
324290
"kernelspec": {
325-
"display_name": "bk-tutorial",
291+
"display_name": "Python 3 (ipykernel)",
326292
"language": "python",
327293
"name": "python3"
328294
},

notebooks/02_installation_and_setup.ipynb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"<table style=\"float:left; border:none\">\n",
88
" <tr style=\"border:none\">\n",
99
" <td style=\"border:none\">\n",
10-
" <a href=\"https://bokeh.org/\">\n",
10+
" <a href=\"https://bokeh.org/\" target=\"_blank\">\n",
1111
" <img\n",
1212
" src=\"assets/bokeh-transparent.png\"\n",
1313
" style=\"width:50px\"\n",
@@ -20,11 +20,10 @@
2020
" </tr>\n",
2121
"</table>\n",
2222
"\n",
23-
"<div style=\"float:right;\"><h2>02 Bokeh Installation and Setup</h2></div>"
23+
"<div style=\"float:right;\"><a href=\"TOC.ipynb\" target=\"_blank\">Table of contents</a><br><h2>02 Bokeh Installation and Setup</h2></div>"
2424
]
2525
},
2626
{
27-
"attachments": {},
2827
"cell_type": "markdown",
2928
"metadata": {},
3029
"source": [
@@ -39,7 +38,6 @@
3938
]
4039
},
4140
{
42-
"attachments": {},
4341
"cell_type": "markdown",
4442
"metadata": {},
4543
"source": [
@@ -67,7 +65,6 @@
6765
]
6866
},
6967
{
70-
"attachments": {},
7168
"cell_type": "markdown",
7269
"metadata": {},
7370
"source": [
@@ -103,7 +100,6 @@
103100
]
104101
},
105102
{
106-
"attachments": {},
107103
"cell_type": "markdown",
108104
"metadata": {},
109105
"source": [
@@ -122,7 +118,7 @@
122118
"source": [
123119
"# Next section\n",
124120
"\n",
125-
"<a href=\"03_basic_concepts.ipynb\">\n",
121+
"<a href=\"03_basic_concepts.ipynb\" target=\"_blank\">\n",
126122
" <img src=\"assets/arrow.svg\" alt=\"Next section\" width=\"100\" align=\"right\">\n",
127123
"</a>\n",
128124
"\n",
@@ -133,7 +129,7 @@
133129
],
134130
"metadata": {
135131
"kernelspec": {
136-
"display_name": "bk-tutorial",
132+
"display_name": "Python 3 (ipykernel)",
137133
"language": "python",
138134
"name": "python3"
139135
},
@@ -147,7 +143,7 @@
147143
"name": "python",
148144
"nbconvert_exporter": "python",
149145
"pygments_lexer": "ipython3",
150-
"version": "3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:16:33) [MSC v.1929 64 bit (AMD64)]"
146+
"version": "3.10.8"
151147
},
152148
"vscode": {
153149
"interpreter": {

notebooks/03_basic_concepts.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"<table style=\"float:left; border:none\">\n",
88
" <tr style=\"border:none\">\n",
99
" <td style=\"border:none\">\n",
10-
" <a href=\"https://bokeh.org/\">\n",
10+
" <a href=\"https://bokeh.org/\" target=\"_blank\">\n",
1111
" <img\n",
1212
" src=\"assets/bokeh-transparent.png\"\n",
1313
" style=\"width:50px\"\n",
@@ -20,7 +20,7 @@
2020
" </tr>\n",
2121
"</table>\n",
2222
"\n",
23-
"<div style=\"float:right;\"><h2>03 Basic Concepts</h2></div>"
23+
"<div style=\"float:right;\"><a href=\"TOC.ipynb\" target=\"_blank\">Table of contents</a><br><h2>03 Basic Concepts</h2></div>"
2424
]
2525
},
2626
{
@@ -60,7 +60,7 @@
6060
"connected to the BokehJS JavaScript library on the browser-side through JSON\n",
6161
"](assets/bokeh_bokehjs.svg)\n",
6262
"\n",
63-
"This tutorial focuses on using Bokeh in Python which generates the BokehJS code\n",
63+
"This tutorial focuses on using Bokeh in Python, which generates the BokehJS code\n",
6464
"automatically. However, you can also use BokehJS directly in JavaScript. For\n",
6565
"more information, see the chapter\n",
6666
"[BokehJS](https://docs.bokeh.org/en/latest/docs/user_guide/advanced/bokehjs.html)\n",
@@ -76,7 +76,7 @@
7676
"You can interact with Bokeh using one of the following two interfaces:\n",
7777
"\n",
7878
"* The high-level **bokeh.plotting** interface: This is Bokeh’s primary\n",
79-
"interface. It is a general-purpose interface which is similar to the plotting\n",
79+
"interface. It is a general-purpose interface similar to the plotting\n",
8080
"interfaces of libraries such as [Matplotlib](http://matplotlib.org/) or\n",
8181
"[Matlab](http://www.mathworks.com/products/matlab/). The bokeh.plotting interface\n",
8282
"takes care of many aspects of your plot automatically. Therefore, it makes it\n",
@@ -197,7 +197,7 @@
197197
"cell_type": "markdown",
198198
"metadata": {},
199199
"source": [
200-
"You'll learn more about widgets in the chapter [TBD]"
200+
"You'll learn more about widgets in chapter [11 Widgets and interactivity](11_widgets_and_interactivity.ipynb)."
201201
]
202202
},
203203
{
@@ -207,7 +207,7 @@
207207
"#### Layouts\n",
208208
"\n",
209209
"A Bokeh document can consist of a single plot. However, you can also combine several\n",
210-
"plots and widges into a more complex visualization. To combine multiple elements in one\n",
210+
"plots and widgets into a more complex visualization. Combining multiple elements in one\n",
211211
"document is called a **layout**. Bokeh provides several different layout options to\n",
212212
"arrange your plots and widgets in a document.\n",
213213
"\n",
@@ -247,7 +247,7 @@
247247
"cell_type": "markdown",
248248
"metadata": {},
249249
"source": [
250-
"You will learn more about layouts in chapter [TBD]"
250+
"You will learn more about layouts in chapter [10 Layouts](10_layouts.ipynb)."
251251
]
252252
},
253253
{
@@ -256,7 +256,7 @@
256256
"source": [
257257
"# Next section\n",
258258
"\n",
259-
"<a href=\"04_basic_plots.ipynb\">\n",
259+
"<a href=\"04_basic_plots.ipynb\" target=\"_blank\">\n",
260260
" <img src=\"assets/arrow.svg\" alt=\"Next section\" width=\"100\" align=\"right\">\n",
261261
"</a>\n",
262262
"\n",

0 commit comments

Comments
 (0)