def render_graph(frames, canvas, frame=None):
    """
    render the graph of intesities against time
        Args:
            frames ([FrameStats]): the frame statistics
            canvas (mapplotlib.FigureCanvas): the canvas
            frame (int): the frame number, if valid provided frame line will be added
        Returns:
            pointer to frame line or None
    """
    means = [x.mean for x in frames]
    std_dev = [x.std_deviation for x in frames]

    upper = [means[a]+x for a, x in enumerate(std_dev)]
    lower = [means[a]-x for a, x in enumerate(std_dev)]
    x_vals = range(0, len(means))

    canvas.axes.plot(x_vals, means, label=r'$\mu$')
    canvas.axes.plot(x_vals, lower, label=r"-$\sigma$")
    canvas.axes.plot(x_vals, upper, label=r"$\sigma$")
    canvas.axes.fill_between(x_vals, lower, upper, alpha=0.2)

    frame_line = None
    if frame is not None and not frame < 0 and not frame >= len(frames):
        line_x = [frame, frame]
        line_y = [5, 250]
        frame_line = canvas.axes.plot(line_x, line_y)

    canvas.axes.set_xlabel('Frame')
    canvas.axes.set_ylabel('Pixel Intensity')
    canvas.axes.set_title('Mean Intensitites')
    canvas.axes.set_ylim(0, 256)

    canvas.axes.legend()

    canvas.draw()

    return frame_line