Interactive Data Visualization with Bokeh
George Boorman
Core Curriculum Manager, DataCamp
sizes = nba["points"] / 50
fig = figure(x_axis_label="Assists", y_axis_label="Points") fig.circle(x=nba["assists"], y=nba["points"], fill_color="purple", radius=sizes)
output_file(filename="glyph_vectorization.html") show(fig)
from bokeh.palettes import Inferno3
from bokeh.palettes import Colorblind4
from bokeh.palettes import __palettes__
__palettes__[:8]
['Accent3',
'Accent4',
'Accent5',
'Accent6',
'Accent7',
'Accent8',
'Blues3',
'Blues4']
from bokeh.transform import linear_cmap
from bokeh.palettes import YlOrBr8
from bokeh.models import ColorBar
mapper = linear_cmap(field_name="points", palette=YlOrBr8, low=min(nba["points"])), high=max(nba["points"]))
fig = figure(x_axis_label="Assists", y_axis_label="Points") fig.circle(x="assists", y="points", source=source, fill_color=mapper, line_color=mapper)
color_bar = ColorBar(color_mapper=mapper["transform"], width=8)
fig.add_layout(color_bar, "right")
output_file(filename="linear_cmap.html") show(fig)
from bokeh.transform import factor_cmap from bokeh.palettes import Category10_5
positions = ["PG", "SG", "SF", "PF", "C"] fig = figure(x_axis_label="Rebounds", y_axis_label="Points") fig.circle(x="rebounds", y="points", source=source,
fill_color=factor_cmap("position", palette=Category10_5, factors=positions),
legend_field="position")
output_file(filename="factor_cmap.html") show(fig)
Interactive Data Visualization with Bokeh