Last updated
Last updated
Note that Bokeh plots created using the bokeh.plotting
interface comes with a default set of tools, and default visual styles. Later we will learn Styling Visual Attributes for information about how to customize the visual style of plots.
All the markers have the same set of properties: x
, y
, size
, and angle
(radians by default).
There are lots of marker types available in Bokeh:
Here is an example to generate a single line glyph from one-dimensional sequences of x and y points using the line()
glyph method and how to draw discrete steps between data points with step()
method.
Sometimes it is useful to plot multiple lines all at once. Then we can usemulti_line()
to accomplish. In some instances, it is desirable to stack lines that are aligned on a common index (e.g. time series of percentages). Then we use vline_stack()
or hline_stack().
When drawing rectangular bars (often representing intervals) it is often more convenient to have coordinates that are a hybrid of the two systems above.
Directed areas are filled regions between two series that share a common index. For instance, a vertical directed area has one x coordinate array, and two y coordinate arrays, y1 and y2, which will be filled between.
A single directed area between two aligned series can be created in the vertical direction with varea()
or in the horizontal direction with harea()
The stacked area can be accomplished with the varea_stack()
and harea_stack()
Below is an example that shows how to generate a single polygonal patch glyph from one- dimensional sequences of x and y points using the patch()
method and how to plot multiple polygonal patches all at once using patches()
Combining multiple glyphs on a single plot is a matter of calling more than one glyph method on a single Figure
By default, Bokeh will attempt to automatically set the data bounds of plots to fit snugly around the data. Sometimes, you may need to set a plot’s range explicitly. Then we use x_range
and y_range
As we can see from the graph, the left one combines the line chart and circle chart to show the trends. Also, the X-axis and Y-axis of the left one do not start with 0. We set the range in the right one and make sure the graph has not been misinterpreted.
to draw vertical bars by specifying a (center) x-coordinate, width, and top and bottom endpoints, use the function.
to draw horizontal bars by specifying a (center) y-coordinate, height, and left and right endpoints, use the function.