Python Bokeh Cheat Sheet
Python Bokeh Cheat Sheet
Python Bokeh Cheat Sheet
glyphs
plot
Python lists, NumPy arrays, Pandas DataFrames and other sequences of values
Rows
Asia
Europe
Columns
Linked Plots
Tabbed Layout
>>>
>>>
>>>
>>>
Linked Axes
Linked Brushing
>>>
>>>
>>>
>>>
>>>
Legends
Legend Location
Inside Plot Area
Legend Orientation
>>>
>>>
>>>
>>>
r1 = p2.asterisk(np.array([1,2,3]), np.array([3,2,1])
r2 = p2.line([1,2,3,4], [3,4,5,6])
legend = Legend(items=[("One" , [p1, r1]),("Two" , [r2])], location=(0, -30))
p.add_layout(legend, 'right')
Bar Chart
>>> from bokeh.charts import Bar
>>> p = Bar(df, stacked=True, palette=['red','blue'])
Box Plot
Embedding
Standalone HTML
Label 1
Label 2
Label 3
Histogram
Scatter Plot
Histogram
Components
x-axis
>>> save(p1)
>>> save(layout)
Notebook Output
Output
>>> from bokeh.io import output_file, show
>>> output_file('my_bar_chart.html', mode='cdn')
Colormapping
US
>>> from bokeh.layouts import row >>> from bokeh.layouts import columns
>>> layout = row(p1,p2,p3)
>>> layout = column(p1,p2,p3)
Plotting
Hover Glyphs
Grid Layout
Data
>>> p = figure(tools='box_select')
>>> p.circle('mpg', 'cyl', source=cds_df,
selection_color='red',
nonselection_alpha=0.1)
y-axis
Line Glyphs
Scatter Markers
data
Customized Glyphs
Glyphs
Bokeh
DataCamp