-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathwest-top-2-race-v0.py
47 lines (40 loc) · 1.15 KB
/
west-top-2-race-v0.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Bokeh libraries
from bokeh.io import output_file
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure, show
# Output to file
output_file(
"west-top-2-standings-race.html",
title="Western Conference Top 2 Teams Wins Race",
)
# Isolate the data for the Rockets and Warriors
rockets_data = west_top_2[west_top_2["teamAbbr"] == "HOU"] # noqa
warriors_data = west_top_2[west_top_2["teamAbbr"] == "GS"] # noqa
# Create a ColumnDataSource object for each team
rockets_cds = ColumnDataSource(rockets_data)
warriors_cds = ColumnDataSource(warriors_data)
# Create and configure the figure
fig = figure(
x_axis_type="datetime",
plot_height=300,
plot_width=600,
title="Western Conference Top 2 Teams Wins Race, 2017-18",
x_axis_label="Date",
y_axis_label="Wins",
toolbar_location=None,
)
# Render the race as step lines
fig.step(
"stDate", "gameWon", color="#CE1141", legend="Rockets", source=rockets_cds
)
fig.step(
"stDate",
"gameWon",
color="#006BB6",
legend="Warriors",
source=warriors_cds,
)
# Move the legend to the upper left corner
fig.legend.location = "top_left"
# Show the plot
show(fig)