summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2020-09-03 12:43:36 +0200
committerDennis Kobert <dennis@kobert.dev>2020-09-03 12:43:36 +0200
commit098dc5ebe1365b151b55ac0286a4f565636f98af (patch)
tree0e27d1a594aed2ae02f2ee85cee1d24bda4c0471
parent1a97aa3953758ef6965d71b88c15963b473da2d3 (diff)
Add numpy plotting
-rwxr-xr-xdiffs.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/diffs.py b/diffs.py
new file mode 100755
index 0000000..8eb0088
--- /dev/null
+++ b/diffs.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+from datetime import datetime
+from phabricator import Phabricator
+import numpy as np
+import matplotlib.pyplot as plt
+import scipy.stats as st
+from sklearn.datasets.samples_generator import make_blobs
+
+start = datetime(year=2020, month=7, day=1)
+
+
+def format_stamp(stamp):
+ dt = datetime.utcfromtimestamp(stamp)
+ date = (dt - start).days
+ 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]
+
+# Extract x and y
+x = [i for i, j in dates]
+y = [j for i, j in dates]
+# Define the borders
+xmin = 0
+xmax = 60
+ymin = 0
+ymax = 24
+print(xmin, xmax, ymin, ymax)
+# Create meshgrid
+xx, yy = np.mgrid[xmin:xmax:100j, ymin:ymax:100j]
+
+positions = np.vstack([xx.ravel(), yy.ravel()])
+values = np.vstack([x, y])
+kernel = st.gaussian_kde(values)
+f = np.reshape(kernel(positions).T, xx.shape)
+
+print(f)
+
+fig = plt.figure(figsize=(13, 7))
+ax = plt.axes(projection='3d')
+surf = ax.plot_surface(xx, yy, f, rstride=1, cstride=1, cmap='coolwarm', edgecolor='none')
+ax.set_xlabel('x')
+ax.set_ylabel('y')
+ax.set_zlabel('PDF')
+ax.set_title('Surface plot of Gaussian 2D KDE')
+fig.colorbar(surf, shrink=0.5, aspect=5) # add color bar indicating the PDF
+ax.view_init(90, -90)
+
+plt.show()
+
+#h =plt.hist2d(x, y)
+#plt.colorbar(h[3])
+#plt.show()
+
+
+#plt.scatter(X[:, 0], X[:, 1], s=50, c = truth)
+#plt.title(f"Example of a mixture of {n_components} distributions")
+#plt.xlabel("x")
+#plt.ylabel("y");