-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathwest-top-2-race-v1.py
56 lines (49 loc) · 1.25 KB
/
west-top-2-race-v1.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
48
49
50
51
52
53
54
55
56
# Bokeh libraries
from bokeh.io import output_file
from bokeh.models import CDSView, ColumnDataSource, GroupFilter
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",
)
# Create a ColumnDataSource
west_cds = ColumnDataSource(west_top_2) # noqa
# Create views for each team
rockets_view = CDSView(
source=west_cds, filters=[GroupFilter(column_name="teamAbbr", group="HOU")]
)
warriors_view = CDSView(
source=west_cds, filters=[GroupFilter(column_name="teamAbbr", group="GS")]
)
# Create and configure the figure
west_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
west_fig.step(
"stDate",
"gameWon",
source=west_cds,
view=rockets_view,
color="#CE1141",
legend="Rockets",
)
west_fig.step(
"stDate",
"gameWon",
source=west_cds,
view=warriors_view,
color="#006BB6",
legend="Warriors",
)
# Move the legend to the upper left corner
west_fig.legend.location = "top_left"
# Show the plot
show(west_fig)