Better histogram

This commit is contained in:
Enrico Lumetti 2021-09-17 23:50:53 +02:00
parent 89728fdcbe
commit 4f02522166
1 changed files with 3 additions and 1 deletions

View File

@ -75,7 +75,9 @@ else:
num_buckets = (max_date - min_date).total_seconds() / (bucket_size * 3600) num_buckets = (max_date - min_date).total_seconds() / (bucket_size * 3600)
num_buckets = max(1, int(num_buckets)) num_buckets = max(1, int(num_buckets))
counts, bin_edges = np.histogram(timestamps, bins=num_buckets) counts, bin_edges = np.histogram(timestamps, bins=num_buckets)
ts_edges = [datetime.fromtimestamp(t) for t in bin_edges]
labels = [x[0].strftime('%Y-%m-%d %H:%M - ') + x[1].strftime('%Y-%m-%d %H:%M') for x in zip(ts_edges[:-1], ts_edges[1:])]
fig = tpl.figure() fig = tpl.figure()
fig.hist(counts, bin_edges) fig.barh(counts, labels)
fig.show() fig.show()