From 098dc5ebe1365b151b55ac0286a4f565636f98af Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Thu, 3 Sep 2020 12:43:36 +0200 Subject: Add numpy plotting --- diffs.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 diffs.py 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"); -- cgit v1.2.3-54-g00ecf