comparison agl.py @ 7:27540ac7879d

Set the graph title
author Daniel O'Connor <darius@dons.net.au>
date Mon, 11 Sep 2017 16:48:10 +0930
parents 2e50426c946f
children 22d31cee19b1
comparison
equal deleted inserted replaced
6:2e50426c946f 7:27540ac7879d
235 ax2.plot(line[0], line[1], label = line[2], color = line[3]) 235 ax2.plot(line[0], line[1], label = line[2], color = line[3])
236 ax2.legend(loc = 'upper right') 236 ax2.legend(loc = 'upper right')
237 237
238 ndays = int(max(1, round(((end - start).total_seconds()) / 86400))) 238 ndays = int(max(1, round(((end - start).total_seconds()) / 86400)))
239 for ax in fig.get_axes(): 239 for ax in fig.get_axes():
240 ax.set_title('%s to %s' % (start.strftime('%Y-%m-%d'), end.strftime('%Y-%m-%d')))
240 ax.set_xlim([start, end]) 241 ax.set_xlim([start, end])
241 ax.format_xdata = lambda d: matplotlib.dates.num2date(d).strftime('%d %b %H:%M') 242 ax.format_xdata = lambda d: matplotlib.dates.num2date(d).strftime('%d %b %H:%M')
242 ax.xaxis.grid(True) 243 ax.xaxis.grid(True)
243 ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%d %b\n%H:%M')) 244 ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%d %b\n%H:%M'))
244 ax.xaxis.set_major_locator(matplotlib.dates.HourLocator(interval = 2 * ndays)) 245 ax.xaxis.set_major_locator(matplotlib.dates.HourLocator(interval = 2 * ndays))