diff --git a/eodb/events/management/commands/times.py b/eodb/events/management/commands/times.py index d1a78cb..cb69735 100644 --- a/eodb/events/management/commands/times.py +++ b/eodb/events/management/commands/times.py @@ -4,6 +4,8 @@ import matplotlib import matplotlib.dates import matplotlib.pyplot as plt +from django.utils.dateparse import parse_date + from .common import GraphCommand @@ -33,9 +35,21 @@ class Command(GraphCommand): plt.legend([plot for legend, plot in plots], [legend for legend, plot in plots]) + if options.get('datemin'): + datemin = parse_date(options['datemin']) + else: + datemin = datetime.date(2000, 1, 1) # past + if options.get('datemax'): + datemax = parse_date(options['datemax']) + else: + datemax = datetime.date.today() + 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')) + if (datemax - datemin).days < 365: + plt.gca().xaxis.set_minor_formatter(matplotlib.dates.DateFormatter('%m/%Y')) + plt.gca().set_ylim([0, 24]) plt.yticks(range(24), list(range(4, 24)) + list(range(0, 4))) self.plot(options)