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
|
#!/usr/bin/env python3
from datetime import datetime
from phabricator import Phabricator
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib.dates as mdates
from scipy.ndimage.filters import gaussian_filter
start = datetime(year=2020, month=7, day=1)
def format_stamp(stamp):
dt = datetime.utcfromtimestamp(stamp)
date = mdates.date2num(dt)
time = dt.hour + dt.minute / 60.0
return [date, time]
phab = Phabricator() # This will use your ~/.arcrc file
diff = phab.differential.query()
dates = []
for d in diff:
created = format_stamp(int(d["dateCreated"]))
modified = format_stamp(int(d["dateModified"]))
dates += [created, modified]
def myplot(x, y, s, bins=1000):
heatmap, xedges, yedges = np.histogram2d(x, y, bins=bins)
heatmap = gaussian_filter(heatmap, sigma=s)
extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]]
return heatmap.T, extent
fig, axs = plt.subplots(2, 2)
sigmas = [0, 16, 32, 48]
x = [i for i, j in dates]
y = [j for i, j in dates]
daymonthFmt = mdates.DateFormatter('%d %B')
for ax, s in zip(axs.flatten(), sigmas):
ax.xaxis.set_major_formatter(daymonthFmt)
_ = plt.xticks(rotation=90)
if s == 0:
ax.plot(x, y, 'k.', markersize=5)
ax.set_title("Scatter plot")
else:
img, extent = myplot(x, y, s)
ax.imshow(img, extent=extent, origin='lower', cmap=cm.jet)
ax.set_title("Smoothing with $\sigma$ = %d" % s)
plt.show()
|