-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy patheast-top-2-race-v0.py
58 lines (51 loc) · 1.28 KB
/
east-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
48
49
50
51
52
53
54
55
56
57
58
# 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(
"east-top-2-standings-race.html",
title="Eastern Conference Top 2 Teams Wins Race",
)
# Create a ColumnDataSource
standings_cds = ColumnDataSource(standings) # noqa
# Create views for each team
celtics_view = CDSView(
source=standings_cds,
filters=[GroupFilter(column_name="teamAbbr", group="BOS")],
)
raptors_view = CDSView(
source=standings_cds,
filters=[GroupFilter(column_name="teamAbbr", group="TOR")],
)
# Create and configure the figure
east_fig = figure(
x_axis_type="datetime",
plot_height=300,
plot_width=600,
title="Eastern 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
east_fig.step(
"stDate",
"gameWon",
color="#007A33",
legend="Celtics",
source=standings_cds,
view=celtics_view,
)
east_fig.step(
"stDate",
"gameWon",
color="#CE1141",
legend="Raptors",
source=standings_cds,
view=raptors_view,
)
# Move the legend to the upper left corner
east_fig.legend.location = "top_left"
# Show the plot
show(east_fig)