Hardware Reference
In-Depth Information
Listing 17-4 continued
facecolor='orange')
#label the y axis
ax.set_ylabel('visit rate per ' + str(intervalSize/60);
+ “mins”)
#label x axis
ax.set_xlabel('Time')
#add title if one specified
if title:
ax.set_title(title)
# format the x axis
# see: http://matplotlib.org/examples/api/date_demo.html
# for more info
ax.xaxis.set_major_locator(DayLocator())
# format major tick boxes as Day of month/Month Hour:Min
ax.xaxis.set_major_formatter(DateFormatter('%d/%m %H:%M'))
ax.xaxis.set_minor_formatter(DateFormatter('%H'))
#uncomment the set_minor_locator function to put minor
#lines for every hour
#if the logging has run for some time, then there are
#too many to display!
#ax.xaxis.set_minor_locator(HourLocator())
# format the coords box, which is displayed when mouse
# is over graph
ax.format_xdata = DateFormatter('%d %H:%M')
ax.grid(True)
fig.autofmt_xdate()
return fig
def drawGraph(events,filename):
#determine the number of bins (bars) on the graph by
#splitting the time the data spans by a time interval.
#calclulate the time spanned by the data
latestReading = num2date(max(events))
earliestReading = num2date(min(events))
dateRange = latestReading - earliestReading
Search WWH ::




Custom Search