'Method to draw a scatterplot of the average time to download links
against time. Add a regression line to show the trend over time.'

def scatterplot(self):

    try:
        from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
        self.FigureCanvas = FigureCanvas
        from matplotlib.figure import Figure
        self.Figure = Figure
        import numpy
    except ImportError:
        return
    try:
        import xlrd
    except:
        import_error += 'ERROR:    the    xlrd    modules    is    needed    to    record    timings\n'
    rec_time_filename = self.config.record_timings_filename
    try:
        workbook = xlrd.open_workbook(filename=rec_time_filename, formatting_info=True)
    except:
        return
    import numpy
    summary = self.read_timings_sheet(workbook)
    (date_summary, gv_mean, gv_std, m, b) = self.report_timings_summary(summary, mean_threshold=10)
    if (len(gv_mean) <= 2):
        return
    fig = Figure(figsize=(5, 2.5))
    canvas = self.FigureCanvas(fig)
    ax = fig.add_subplot(111)
    linear = numpy.poly1d([m, b])
    denom = (numpy.max(gv_std) / 50)
    size = (gv_std / denom)
    ax.scatter(date_summary, gv_mean, marker='d', s=size)
    ax.plot(date_summary, linear(date_summary), '--r')
    chart = StringIO()
    canvas.print_figure(chart)
    image = chart.getvalue()
    import base64
    base64Img = base64.b64encode(image)
    image = ('<img    src="data:image/png;base64,%s">' % base64Img)
    self.reporter('Scatterplot    of    average    link    times    per    successful    run')
    self.reporter(image)
    self.reporter(('The    trend    line    has    a    current    slope    of    %s' % m))
    self.reporter(('The    y-intercept    is    %s    seconds' % b))
