set appropriate xticks for datetimes

This commit is contained in:
Frédéric Péters 2017-10-15 21:25:46 +02:00
parent 500e74a9ef
commit 74c5cecd45
2 changed files with 4 additions and 0 deletions

View File

@ -51,5 +51,7 @@ class Command(GraphCommand):
values = [events[x] for x in dates]
plt.bar(dates, values, width=20)
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'))
self.plot(options)

View File

@ -19,6 +19,8 @@ class Command(GraphCommand):
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))