|
7 | 7 | "<table style=\"float:left; border:none\">\n",
|
8 | 8 | " <tr style=\"border:none\">\n",
|
9 | 9 | " <td style=\"border:none\">\n",
|
10 |
| - " <a href=\"https://bokeh.org/\">\n", |
| 10 | + " <a href=\"https://bokeh.org/\" target=\"_blank\">\n", |
11 | 11 | " <img\n",
|
12 | 12 | " src=\"assets/bokeh-transparent.png\"\n",
|
13 | 13 | " style=\"width:50px\"\n",
|
|
20 | 20 | " </tr>\n",
|
21 | 21 | "</table>\n",
|
22 | 22 | "\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>" |
24 | 24 | ]
|
25 | 25 | },
|
26 | 26 | {
|
27 |
| - "attachments": {}, |
28 | 27 | "cell_type": "markdown",
|
29 | 28 | "metadata": {},
|
30 | 29 | "source": [
|
31 | 30 | "### What is Bokeh?\n",
|
32 | 31 | "\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", |
34 | 33 | "browsers**.\n",
|
35 | 34 | "\n",
|
36 | 35 | "With Bokeh, you can use Python to build beautiful data visualizations, ranging from\n",
|
|
67 | 66 | "source": [
|
68 | 67 | "# create a complex chart with mouse-over tooltips\n",
|
69 | 68 | "\n",
|
70 |
| - "from bokeh.models import ColumnDataSource, HoverTool\n", |
| 69 | + "from bokeh.palettes import HighContrast3\n", |
71 | 70 | "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", |
74 | 71 | "\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", |
77 | 76 | "\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", |
80 | 78 | "\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", |
89 | 80 | "\n",
|
| 81 | + "p.y_range.start = 0\n", |
| 82 | + "p.x_range.range_padding = 0.1\n", |
90 | 83 | "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", |
113 | 88 | "\n",
|
114 | 89 | "show(p)"
|
115 | 90 | ]
|
116 | 91 | },
|
117 | 92 | {
|
118 |
| - "attachments": {}, |
119 | 93 | "cell_type": "markdown",
|
120 | 94 | "metadata": {},
|
121 | 95 | "source": [
|
|
130 | 104 | "[\"T-100 Domestic Market\"](https://transtats.bts.gov/DL_SelectFields.aspx?gnoyr_VQ=FIL&QO_fu146_anzr=Nv4%20Pn44vr45)\n",
|
131 | 105 | "dataset of airline routes within the United States for the year 2021.\n",
|
132 | 106 | "\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>" |
134 | 110 | ]
|
135 | 111 | },
|
136 | 112 | {
|
|
139 | 115 | "metadata": {},
|
140 | 116 | "outputs": [],
|
141 | 117 | "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", |
146 | 119 | "from tutorial_dashboard import dashboard_layout\n",
|
147 | 120 | "\n",
|
148 |
| - "# show dashboard\n", |
149 | 121 | "show(dashboard_layout)"
|
150 | 122 | ]
|
151 | 123 | },
|
|
154 | 126 | "cell_type": "markdown",
|
155 | 127 | "metadata": {},
|
156 | 128 | "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", |
158 | 130 | "with the different elements of the dashboard.\n",
|
159 | 131 | "\n",
|
160 | 132 | "The tutorial will walk you through all the steps of creating this dashboard, introducing\n",
|
|
179 | 151 | "* [11 Widgets and interactivity](11_widgets_interactivity.ipynb)\n",
|
180 | 152 | "* [12 Building the demo dashboard](12_demo_dashboard.ipynb)\n",
|
181 | 153 | "* [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!" |
183 | 158 | ]
|
184 | 159 | },
|
185 | 160 | {
|
186 |
| - "attachments": {}, |
187 | 161 | "cell_type": "markdown",
|
188 | 162 | "metadata": {},
|
189 | 163 | "source": [
|
|
215 | 189 | ]
|
216 | 190 | },
|
217 | 191 | {
|
218 |
| - "attachments": {}, |
219 | 192 | "cell_type": "markdown",
|
220 | 193 | "metadata": {},
|
221 | 194 | "source": [
|
|
227 | 200 | "Run each code cell as you make your way through each chapter.\n",
|
228 | 201 | "\n",
|
229 | 202 | "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." |
235 | 204 | ]
|
236 | 205 | },
|
237 | 206 | {
|
238 |
| - "attachments": {}, |
239 | 207 | "cell_type": "markdown",
|
240 | 208 | "metadata": {},
|
241 | 209 | "source": [
|
|
274 | 242 | ]
|
275 | 243 | },
|
276 | 244 | {
|
277 |
| - "attachments": {}, |
278 | 245 | "cell_type": "markdown",
|
279 | 246 | "metadata": {},
|
280 | 247 | "source": [
|
|
303 | 270 | ]
|
304 | 271 | },
|
305 | 272 | {
|
306 |
| - "attachments": {}, |
307 | 273 | "cell_type": "markdown",
|
308 | 274 | "metadata": {},
|
309 | 275 | "source": [
|
310 | 276 | "# Next section\n",
|
311 | 277 | "\n",
|
312 |
| - "<a href=\"02_installation_and_setup.ipynb\">\n", |
| 278 | + "<a href=\"02_installation_and_setup.ipynb\" target=\"_blank\">\n", |
313 | 279 | " <img src=\"assets/arrow.svg\" alt=\"Next section\" width=\"100\" align=\"right\">\n",
|
314 | 280 | "</a>\n",
|
315 | 281 | "\n",
|
|
322 | 288 | ],
|
323 | 289 | "metadata": {
|
324 | 290 | "kernelspec": {
|
325 |
| - "display_name": "bk-tutorial", |
| 291 | + "display_name": "Python 3 (ipykernel)", |
326 | 292 | "language": "python",
|
327 | 293 | "name": "python3"
|
328 | 294 | },
|
|
0 commit comments