In this tutorial, the instructor introduces the Bokeh plotting interface as a simple yet flexible way to create interactive visualizations in Python. The session covers the basic workflow: importing Bokeh I/O functions (outputfile, show) and the figure constructor, configuring plot dimensions and tools (e.g., pan, boxzoom), and adding glyphs such as circles to an empty figure. The concept of glyphs is explained, highlighting their visual properties (position, size, color, alpha) and how these properties can be driven by data sequences (lists, tuples, NumPy arrays, Pandas columns) or set to fixed values. The tutorial demonstrates creating a circle glyph with x and y coordinate lists, discusses default property values, and shows how to output the plot to an HTML file for browser display. Finally, it mentions the variety of built‑in marker shapes available in Bokeh and the flexibility of configuring glyph properties.
Chapters
In this first chapter we will take a look at the Bokeh Plotting interface. This is a simple but flexible interface that is a good place to get started using Bokeh. This interface gives you a basic empty plot with sensible but customizable defaults for things like axes, grids and tools. Into this plot you can add glyphs that connect visual properties directly to your data. So what are glyphs? Glyphs are visual shapes that can be drawn on the screen. These can be simple point like markers such as circles, squares or triangles, or more sophisticated shapes such as rectangles, lines, patches, wedges and others. In every case, these shapes have visual properties that can include things like position or x and y coordinates for locating a shape on the plot size or radius fill and outline colors or transparency, also called alpha. Let's see what this looks like in typical usage. First, in order to use Bokeh plotting and also to see our results, there are some standard Python imports. Here we see from Bokeh IO import output file and show. These two functions make it easy to save the plots we make in an HTML file and open up a browser to display that file. It's also worth mentioning that we could instead import Output Notebook in order to display plots inline in a Jupyter notebook. Although we will not be using Jupyter notebooks in this course, they are very common in the world of data science. We also see from Bokeh plotting import figure the figure function is what creates the basic empty plot with sensible defaults I mentioned earlier, and it's all that's required to get started using the Bokeh plotting interface. Next, we call the figure function with some arguments that control general properties of a plot. In this case we have passed plot width equals 400 to specify that the overall canvas for drawing the plot should be 400 pixels wide. There's a corresponding plot height. If you want to change the default canvas height. We also have passed in the Argument Tools pan boxzoom. This tools parameter can accept a list of actual tool objects or more commonly a comma separated string that lists the names of built in tools. In this case, we choose to add a tool for panning the plot region and a tool for drawing rectangular regions. To zoom in on, we call the circle method on the plot returned by figure. In this example, we pass two python lists that represent the x and y coordinates of the circles respectively. All other visual properties such as size, color, etc. Will take on default values. Finally, we call some functions to display the Results. We call OutputFile to specify that we want to save the output to an HTML file, then we call show, which saves the file and conveniently opens a browser to display it. What kinds of values can be attached to glyph properties? We've seen that Python lists can be passed in, but more generally any sequence type will do. Tuples, arrays, columns from Pandas, dataframes all work well. It's also possible to configure properties with a single fixed value. In that case, however, many glyphs are actually drawn, they will all have the same value for that property. This has already happened implicitly in the previous example we supplied lists for the X and Y coordinates, but the size, color and transparency had single default values that carried over to every circle that was actually drawn in the example code. Here we've set the x value to 10, but given lists y and for size in the output we can see that all the circles are centered at x equals 10, but that the y values and sizes vary according to the lists that we passed in the first set of exercises will give us practice with marker like glyphs, we will use circles throughout, but I should mention that Bokeh comes with many standard marker shapes built in. Here's a list of all the built in markers.