This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
eodb/eodb/events/management/commands/times.py

28 lines
1020 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_events(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_locator(matplotlib.dates.YearLocator())
plt.gca().xaxis.set_minor_locator(matplotlib.dates.MonthLocator())
plt.gca().xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%m/%Y'))
plt.gca().set_ylim([0, 24])
plt.yticks(range(24))
self.plot(options)