Menambahkan LassoSelectTool

Visualisasi Data Interaktif dengan Bokeh

George Boorman

Core Curriculum Manager, DataCamp

Inspector

 

  • CrosshairTool
    • crosshair Alat Crosshair

 

 

  • HoverTool
    • hover Alat Hover

CrosshairTool

1 https://docs.bokeh.org/en/latest/docs/user_guide/tools.html#userguide-tools-inspectors
Visualisasi Data Interaktif dengan Bokeh

Objek sumber data Bokeh

from bokeh.models import ColumnDataSource

source = ColumnDataSource(data=nba)
fig = figure(x_axis_label="Minutes Played", y_axis_label="Points Per Game")
fig.circle(x="assists", y="points", source=source)
output_file(filename="ColumnDataSource.html") show(fig)

sebar_nba

Visualisasi Data Interaktif dengan Bokeh

Menyiapkan HoverTool

from bokeh.models import ColumnDataSource
source = ColumnDataSource(data=nba)

TOOLTIPS = [("Name", "@player"), ("Team", "@team")]
fig = figure(x_axis_label="Assists", y_axis_label="Points",
tooltips=TOOLTIPS)
fig.circle(x="assists", y="points", source=source) output_file("name_and_team.html") show(fig)
Visualisasi Data Interaktif dengan Bokeh

HoverTool dalam aksi

HoverTool

Visualisasi Data Interaktif dengan Bokeh

Menampilkan data numerik

TOOLTIPS = [("Name", "@player"), ("Team", "@team"),

("Points", "@points"), ("Assists", "@assists")]
fig = figure(x_axis_label="Assists", y_axis_label="Points", tooltips=TOOLTIPS) fig.circle(x="assists", y="points", source=source) output_file("hovertool.html") show(fig)

HoverTool tanpa format

Visualisasi Data Interaktif dengan Bokeh

Memformat HoverTool

TOOLTIPS = [("Name", "@player"), ("Team", "@team"),

("Points", "@points{0.2f}"), ("Assists", "@assists{0.2f}")]
fig = figure(x_axis_label="Assists", y_axis_label="Points", tooltips=TOOLTIPS) fig.circle(x="assists", y="points", source=source) output_file("formatted_hovertool.html") show(fig)

hovertool_terformat

Visualisasi Data Interaktif dengan Bokeh

Ayo berlatih!

Visualisasi Data Interaktif dengan Bokeh

Preparing Video For Download...