summaryrefslogtreecommitdiff
path: root/.local/bin/plot_commits
blob: 4e4d161f42cbe56ea446dbd77d12d391848ee91d (plain)
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
#!/usr/bin/env bash

set -e

[ -n "${1}" ] && cd $1

REPOSITORY=$(basename $(git rev-parse --show-toplevel))

COMMITS=$(commits_by_hour -v \
  | sed -E 's/^/[/;s/$/],/;s/ /,/;s/0([0-9]+)/\1/g' \
  | tr -d '\n' \
  | sed -E 's/^/x,y = zip(*[/;s/$/])/')

python -c "from matplotlib import pyplot as plt;\
           import numpy as np;\
           $COMMITS;\
           ymax=int(np.ceil(max(y) + (max(y)/10)));\
           plt.grid(which='major',alpha=0.5,linestyle='--',axis='y');\
           plt.bar(x,y,align='edge',width=1.0,color='#6fd0ff',edgecolor='#07a');\
           plt.ylabel('Commits');\
           plt.xlabel('Time');\
           plt.title('Commits by the hour of the day, ${REPOSITORY}.git');\
           plt.xlim(0,24);\
           plt.ylim(0,ymax);\
           plt.xticks(np.arange(0,24));\
           plt.yticks(np.arange(0,ymax,max(1,int(np.ceil(ymax/15)))));\
           plt.show()"