Interactive Data Visualization with Bokeh
George Boorman
Core Curriculum Manager, DataCamp
caliberdark_minimallight_minimalnight_skycontrastfrom bokeh.io import curdoccurdoc().theme = "dark_minimal"fig = figure(x_axis_label="Assists", y_axis_label="Points") fig.circle(x=nba["assists"], y=nba["points"]) output_file("dark_minimal.html") show(fig)

east = nba.loc[nba["conference"] == "East"]
west = nba.loc[nba["conference"] == "West"]
print(nba.columns, '\n', east.shape, '\n', west.shape)
Index(['player', 'position', 'minutes', 'field_goal_perc', 'three_point_perc', 'free_throw_perc',
'rebounds', 'assists', 'steals', 'blocks', 'points', 'team', 'conference'],
dtype='object')
(211, 13)
(215, 13)
fig = figure(x_axis_label="Assists per Game", y_axis_label="Points per Game")fig.circle(x=east["assists"], y=east["points"], color="blue")fig.circle(x=west["assists"], y=west["points"], color="red")output_file(filename="east_vs_west.html") show(fig)

fig = figure(x_axis_label="Assists per Game", y_axis_label="Points per Game")fig.circle(x=east["assists"], y=east["points"], color="blue", legend_label="East")fig.circle(x=west["assists"], y=west["points"], color="red", legend_label="West")output_file(filename="east_vs_west_with_legend.html") show(fig)




fig = figure(x_axis_label='Minutes Played', y_axis_label="Points Per Game")fig.square(x=nba["minutes_played"], y=nba["points_per_game"])output_file(filename="nba_points.html") show(fig)

fig = figure(x_axis_label="Assists per Game", y_axis_label="Points per Game")fig.diamond(x=east["assists"], y=east["points"], color="blue", legend_label="Eastern Conference")fig.triangle(x=west["assists"], y=west["points"], color="red", legend_label="Western Conference")output_file(filename="multiple_glyphs.html") show(fig)

print(melb.columns)
Index(['rooms', 'type', 'price', 'date', 'distance', 'bedrooms', 'bathrooms',
'car', 'land_area', 'building_area', 'year_built', 'council_area',
'region'],
dtype='object')
print(melb.shape)
(13580, 13)
Interactive Data Visualization with Bokeh