Skip to content

Commit 01b37f2

Browse files
authored
Various small updates and fixes (#7)
* Set Bokeh lower bound to v3.2 * Small updates and fixes * Update chapter 9 * Add pre-commit info * Update chapters 7 and 8
1 parent e65f4e2 commit 01b37f2

File tree

8 files changed

+51
-28
lines changed

8 files changed

+51
-28
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ is expected to follow the
7171
[Code of Conduct](https://github.com/bokeh/bokeh/blob/main/docs/CODE_OF_CONDUCT.md).
7272
This includes working on these tutorials!
7373

74+
## Preparing your environment
75+
76+
The ``bk-tutorial`` environment includes the necessary dependencies to contribute to
77+
this repository. The only exception if [pre-commit](https://pre-commit.com/), which
78+
you can install with the following command (after activating the ``bk-tutorial``
79+
environment):
80+
81+
```bash
82+
pre-commit install
83+
```
84+
85+
This way, some basic linting and formatting checks will be run on your code before
86+
you commit it.
87+
88+
## Making changes
89+
7490
Contributing to this tutorial repository works similarly to
7591
[contributing to Bokeh itself](https://docs.bokeh.org/en/latest/docs/dev_guide.html):
7692

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
dependencies:
55
- black
6-
- bokeh>=3.0.0
6+
- bokeh>=3.2.0
77
- firefox
88
- flake8
99
- geckodriver

notebooks/05_styling.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@
741741
"\n",
742742
"# 🔁 uncomment different lines to see different themes\n",
743743
"# curdoc().theme = \"caliber\"\n",
744-
"curdoc().theme = \"dark_minimal\"\n",
744+
"# curdoc().theme = \"dark_minimal\"\n",
745745
"# curdoc().theme = \"light_minimal\"\n",
746-
"# curdoc().theme = \"night_sky\"\n",
746+
"curdoc().theme = \"night_sky\"\n",
747747
"# curdoc().theme = \"contrast\"\n",
748748
"\n",
749749
"# create a plot\n",

notebooks/06_data_sources.ipynb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
"inputs for your data.\n",
5959
"\n",
6060
"Behind the scenes, Bokeh converts all these inputs to a Bokeh **ColumnDataSource**.\n",
61-
"This is **Bokeh's internal data structure**. It is used in all plots.\n",
61+
"This is **Bokeh's primary internal data structure**. It is used in almost all plots\n",
62+
"(with the exception of [map plots](#Map-plots)).\n",
6263
"\n",
6364
"In most cases, Bokeh can just handle the ColumnDataSource automatically. However,\n",
6465
"there are many cases where it is useful to create and use a ColumnDataSource\n",
@@ -107,7 +108,7 @@
107108
"source = ColumnDataSource(\n",
108109
" data={\n",
109110
" \"x\": [1, 2, 3, 4, 5], # first dictionary creates a column named \"x\"\n",
110-
" \"y\": [3, 7, 8, 5, 1], # second dictionary creates a column named \"x\"\n",
111+
" \"y\": [3, 7, 8, 5, 1], # second dictionary creates a column named \"y\"\n",
111112
" }\n",
112113
")"
113114
]
@@ -326,7 +327,7 @@
326327
"p.line(\n",
327328
" x=\"month_name\", # use the sequence of strings from the \"month_name\" column as categories\n",
328329
" y=\"freight\", # use the sequence of values from the \"freight\" column as values\n",
329-
" # y=\"mail\", # use this line instead of the one above to use data from the \"mail\" column\n",
330+
" # y=\"mail\", # 🔁 use this line instead of the one above to use data from the \"mail\" column\n",
330331
" source=source,\n",
331332
")\n",
332333
"\n",
@@ -352,7 +353,7 @@
352353
"Using ColumnDataSource objects also allows you to use Bokeh's built-in transforms.\n",
353354
"Transforms are useful for performing computations on the data before the data is\n",
354355
"displayed.\n",
355-
"These transforms are run by BokehJS, in the browser.\n",
356+
"These transforms are performed by BokehJS, in the browser.\n",
356357
"This means the underlying data is not modified and is always available for other plots\n",
357358
"in the same document.\n",
358359
"\n",
@@ -392,7 +393,7 @@
392393
"# create a bar chart with cumulative data from the \"mail\" column\n",
393394
"p.vbar(\n",
394395
" x=\"month_name\",\n",
395-
" top=cumsum(\"mail\", include_zero=True), # use the cumulative sums of the \"mail\" column as values\n",
396+
" top=cumsum(\"passengers\", include_zero=True), # use the cumulative sums of the \"passengers\" column as values\n",
396397
" width=0.9,\n",
397398
" source=source,\n",
398399
")\n",
@@ -409,7 +410,10 @@
409410
"#### The linear_cmap transform\n",
410411
"\n",
411412
"The ``linear_cmap`` transform generates a new sequence of colors by **applying a linear\n",
412-
"color map** to a ColumnDataSource column.\n"
413+
"color map** to a ColumnDataSource column.\n",
414+
"\n",
415+
"See [05 Styling plots](05_styling.ipynb#Color-mappers-and-palettes) for more information\n",
416+
"about color mappers."
413417
]
414418
},
415419
{

notebooks/07_annotations.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@
197197
"By default, these coordinates are in **data-space units**. This means they use the same\n",
198198
"units as the x- and y-axes of your plot. This is helpful if you want to place a label\n",
199199
"relative to a specific data point. To define the position of a label in pixels, set the\n",
200-
"``x_units`` and ``y_units`` parameters to **screen units**. See\n",
200+
"``x_units`` and ``y_units`` parameters to **screen units**. \n",
201+
"Screen and data-space units is a concept that you can use in many places in Bokeh\n",
202+
"(including with Spans). See\n",
201203
"[Screen units and data-space units](https://docs.bokeh.org/en/latest/docs/user_guide/styling/visuals.html#screen-units-and-data-space-units)\n",
202204
"in the Bokeh user guide for more information.\n",
203205
"\n",

notebooks/08_plot_tools.ipynb

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
"source": [
5454
"This chapter provides an overview of the tools that are available in the Bokeh toolbar.\n",
5555
"\n",
56+
"![Example of Bokeh toolbar](assets/bokeh_toolbar.png)\n",
57+
"\n",
5658
"The Bokeh toolbar is a collection of tools that are displayed together with a plot.\n",
5759
"You have seen the toolbar in all previous examples. This chapter is about configuring\n",
5860
"the toolbar and its tools."
@@ -112,7 +114,7 @@
112114
"When you configure the toolbar with the ``figure()`` method, you can specify **which\n",
113115
"tools to include**.\n",
114116
"\n",
115-
"You can pass a list of tool names to the `tools` argument. The following list contains\n",
117+
"You can pass a sequence of tool names to the `tools` argument. The following list contains\n",
116118
"some of the most commonly used tools for viewing data:\n",
117119
"\n",
118120
"* `pan` - pan the plot\n",
@@ -139,7 +141,7 @@
139141
"# set up a figure with a toolbar\n",
140142
"p = figure(\n",
141143
" height=300,\n",
142-
" tools=[\"box_zoom\", \"wheel_zoom\", \"save\"], # 🔁 swap out tools from the list above\n",
144+
" tools=(\"box_zoom\", \"wheel_zoom\", \"save\"), # 🔁 swap out tools from the list above\n",
143145
")\n",
144146
"\n",
145147
"p.line(x=list(range(10)), y=list(range(10)))\n",
@@ -167,16 +169,15 @@
167169
"source": [
168170
"### Defining active tools\n",
169171
"\n",
170-
"By default, Bokeh will activate the first tool in the list of tools. You can **change\n",
171-
"which tools are active** by setting the ``active_drag``, ``active_inspect``,`\n",
172+
"You can **change which tools are active** by setting the ``active_drag``, ``active_inspect``,\n",
172173
"``active_scroll``, and ``active_tap`` properties of a toolbar.\n",
173174
"\n",
174175
"The reason why Bokeh has separate properties for different types of tools is that\n",
175176
"you can have several tools of different types active at the same time. For example,\n",
176177
"you can have an active scroll tool and an active inspect tool at the same time.\n",
177178
"\n",
178-
"The following code cell uses the ``xwenel_zoom`` tool as its active scroll tool.\n",
179-
"Update the code in line 7 to make the ``ywheel_zoom`` tool active by default instead:"
179+
"The following code cell uses the ``xpan`` tool as its active drag tool.\n",
180+
"Update the code in line 7 to make the ``ypan`` tool active by default instead:"
180181
]
181182
},
182183
{
@@ -190,8 +191,8 @@
190191
"# set up a figure with a toolbar\n",
191192
"p = figure(\n",
192193
" height=300,\n",
193-
" tools=[\"reset\", \"wheel_zoom\", \"xwheel_zoom\", \"save\"],\n",
194-
" active_scroll=\"xwheel_zoom\", # 🔁 update this line to make \"xwheel_zoom\" the active scroll tool\n",
194+
" tools=(\"reset\", \"pan\", \"ypan\", \"xpan\", \"save\"),\n",
195+
" active_drag=\"xpan\", # 🔁 update this line to make \"ypan\" the active drag tool\n",
195196
")\n",
196197
"\n",
197198
"p.line(x=list(range(10)), y=list(range(10)))\n",
@@ -208,7 +209,7 @@
208209
"The `HoverTool` is a special tool that **displays a tooltip when the user hovers the\n",
209210
"mouse over a data point or taps on a data point**.\n",
210211
"\n",
211-
"To enable tooltips, you need to add a `HoverTool` to the list of tools. You can then\n",
212+
"To enable tooltips, you need to add a `hover` tool to the list of tools. You can then\n",
212213
"use the `tooltips` argument to specify which data fields to display in the tooltip.\n",
213214
"\n",
214215
"Run the cell below and hover over the data points:"
@@ -225,20 +226,20 @@
225226
"\n",
226227
"source = ColumnDataSource(\n",
227228
" data={\n",
228-
" \"x\": [1, 2, 3, 4, 5],\n",
229-
" \"y\": [3, 7, 8, 5, 1],\n",
229+
" \"x\": [1, 2, 3, 6, 9],\n",
230+
" \"y\": [3, 7, 8, 2, 1],\n",
230231
" }\n",
231232
")\n",
232233
"\n",
233234
"p = figure(\n",
234235
" toolbar_location=None,\n",
235-
" tools=[HoverTool()], # add the HoverTool to the figure\n",
236-
" tooltips=\"Data point @x has the value @y\", # define a tooltip using data from the x and y columns\n",
236+
" tools=\"hover\", # add the hover tool to the figure (the hover tool will work even if the toolbar is hidden)\n",
237+
" tooltips=\"Data point is at @x, @y\", # define a tooltip using data from the x and y columns\n",
237238
" height=300,\n",
238239
")\n",
239240
"\n",
240241
"# add renderers\n",
241-
"p.circle(\"x\", \"y\", size=10, source=source)\n",
242+
"p.circle(\"x\", \"y\", size=25, source=source)\n",
242243
"p.line(\"x\", \"y\", line_width=2, source=source)\n",
243244
"\n",
244245
"# show the results\n",
@@ -253,7 +254,7 @@
253254
"The text that is displayed in the tooltip uses **special syntax to refer to data from\n",
254255
"the ColumnDataSource**.\n",
255256
"\n",
256-
"In the example above, the tooltip text is `\"Data point @x has the value @y\"`. The `@x`\n",
257+
"In the example above, the tooltip text is `\"Data point is at @x, @y`. The `@x`\n",
257258
"and `@y` are replaced with the actual value of the `x` and `y` columns in the\n",
258259
"ColumnDataSource at that point.\n",
259260
"\n",

notebooks/09_more_plot_types.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@
368368
"The next code cell contains the code to create this visualization.\n",
369369
"\n",
370370
"You'll recognize several elements from the previous chapters. For example:\n",
371-
"* Tooltips,\n",
371+
"* Tooltips\n",
372372
"* Configuring plot tools\n",
373373
"* Configuring visual elements of the plot\n",
374374
"* Using a ColorMapper to map values to colors from a palette\n",
@@ -471,7 +471,7 @@
471471
"cell_type": "markdown",
472472
"metadata": {},
473473
"source": [
474-
"Next, calculate the angle for each wedge:"
474+
"Next, calculate the angle for each wedge (in radians):"
475475
]
476476
},
477477
{
@@ -679,7 +679,7 @@
679679
"# configure tooltips\n",
680680
"TOOLTIPS = [\n",
681681
" (\"Carrier\", \"@unique_carrier_name\"),\n",
682-
" (\"Passengers\", \"@passengers{{(0,0)}}\"),\n",
682+
" (\"Passengers\", \"@passengers{(0,0)}\"),\n",
683683
"]\n",
684684
"\n",
685685
"# create a ColumnDataSource from the DataFrame\n",

notebooks/assets/bokeh_toolbar.png

6.65 KB
Loading

0 commit comments

Comments
 (0)