Skip to content

Commit 1df7f94

Browse files
committed
WIP: Use bokeh instead of matplotlib.
1 parent 31e905d commit 1df7f94

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

site/index.md

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ p.add_layout(legend, "below")
139139
show(p)
140140
```
141141

142+
% TODO: Figure out why bokeh won't render when output_notebook is in a hidden cell
143+
144+
```{code-cell} ipython3
145+
---
146+
tags: []
147+
---
148+
# For interactive plots
149+
from bokeh.plotting import figure, show, output_notebook
150+
from bokeh.palettes import Category10_10 as palette
151+
output_notebook()
152+
```
153+
142154
% TODO: automate project generation based on which data files are in devstats-data
143155

144156
```{code-cell} ipython3
@@ -196,7 +208,7 @@ for proj in projects:
196208

197209
```{code-cell} ipython3
198210
---
199-
tags: [remove-input]
211+
tags: [remove-cell]
200212
---
201213
# Num merged PRs per month
202214
start_date = today - year
@@ -206,10 +218,8 @@ bedges = np.array(
206218
# Proxy date for center of bin
207219
x = bedges[:-1] + np.timedelta64(15, "D")
208220
209-
fig, ax = plt.subplots(figsize=(16, 12))
210-
ax.set_title("Merged PRs", fontsize=24)
211-
212221
# NOTE: np.histogram doesn't work on datetimes
222+
merged_prs_per_month = dict()
213223
for proj, data in project_prs.items():
214224
merged_prs = data["merged_prs"]
215225
merge_dates = np.array([pr["mergedAt"] for pr in merged_prs], dtype="M8[D]")
@@ -218,7 +228,20 @@ for proj, data in project_prs.items():
218228
num_merged_per_month.append(
219229
sum(1 for md in merge_dates if md > lo and md < hi)
220230
)
221-
ax.plot(x, num_merged_per_month, label=proj)
222-
ax.legend()
223-
plt.show()
231+
merged_prs_per_month[proj] = num_merged_per_month
232+
```
233+
234+
```{code-cell} ipython3
235+
---
236+
tags: [remove-input]
237+
---
238+
p = figure(
239+
width=400,
240+
height=400,
241+
title="Merged PRs per month",
242+
x_axis_type="datetime",
243+
)
244+
for (label, y), color in zip(merged_prs_per_month.items(), itertools.cycle(palette)):
245+
p.line(x, y, color=color, legend_label=label)
246+
show(p)
224247
```

0 commit comments

Comments
 (0)