#!/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");