26 lines
872 B
Python
26 lines
872 B
Python
import matplotlib
|
|
import matplotlib.dates
|
|
import matplotlib.pyplot as plt
|
|
|
|
from .common import GraphCommand
|
|
|
|
|
|
class Command(GraphCommand):
|
|
def handle(self, *args, **options):
|
|
datetime_var = 'author_datetime'
|
|
if options.get('committime'):
|
|
datetime_var = 'commit_datetime'
|
|
|
|
event_dates = []
|
|
event_times = []
|
|
for commit in self.get_commits(options):
|
|
graph_date = getattr(commit, datetime_var)
|
|
event_dates.append(matplotlib.dates.date2num(graph_date.date()))
|
|
event_times.append(graph_date.hour + graph_date.minute / 60. + graph_date.second / 3600)
|
|
|
|
plt.scatter(event_dates, event_times, alpha=0.3)
|
|
plt.gca().xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%m/%Y'))
|
|
plt.gca().set_ylim([0, 24])
|
|
plt.yticks(range(24))
|
|
self.plot(options)
|