def plot_burstness(corpus, B, **kwargs):
    """
    Generate a figure depicting burstness profiles for ``feature``.

    Parameters
    ----------
    B

    Returns
    -------
    fig : :class:`matplotlib.figure.Figure`

    Examples
    --------

    .. code-block:: python

       >>> from tethne.analyze.corpus import burstness
       >>> fig = plot_burstness(corpus, 'citations', topn=2, perslice=True)
       >>> fig.savefig('~/burstness.png')

    Years prior to the first occurrence of each feature are grayed out. Periods
    in which the feature was bursty are depicted by colored blocks, the opacity
    of which indicates burstness intensity.

    .. figure:: _static/images/burstness.png
       :width: 600
       :align: center
    """
    try:
        import matplotlib.pyplot as plt
        import matplotlib.patches as mpatches
    except ImportError:
        raise RuntimeError('This method requires the package matplotlib.')

    color = kwargs.get('color', 'red')

    # Get width based on slices.
    years = sorted(corpus.indices['date'].keys())
    width = years[1] - years[0]
    height = 1.0

    fig = plt.figure(figsize=(10,len(B)/4.))

    f = 1
    axes = {}
    for key, value in B.iteritems():
        x,y = value
        ax = fig.add_subplot(len(B),1,f)
        f+=1
        ax.set_yticks([])
        ax.set_xbound(min(years), max(years) + 1)

        if not f == len(B)+1:   # Only show xticks on the bottom subplot.
            ax.set_xticklabels([])

        # Block out years until first occurrence of feature.

        rect = mpatches.Rectangle((min(years), 0), sorted(x)[0]-min(years),
                                   height, fill=True, linewidth=0.0)
        rect.set_facecolor('black')
        rect.set_alpha(0.3)
        ax.add_patch(rect)

        # Add a rectangle for each year, shaded according to burstness state.
        for d in xrange(min(x), max(x)):
            try:
                i = x.index(d)
            except ValueError:
                continue

            xy = (d, 0.)

            state = y[i]
            rect = mpatches.Rectangle(xy, width, height,
                                      fill=True, linewidth=0.0)
            rect.set_facecolor(color)
            rect.set_alpha(state)
            ax.add_patch(rect)

        ax.set_ylabel(key, rotation=0,
                      horizontalalignment='right',
                      verticalalignment='center')
    plt.subplots_adjust(left=0.5)
    fig.tight_layout(h_pad=0.25)

    plt.show()
Generate a figure depicting burstness profiles for ``feature``.

    Parameters
    ----------
    B

    Returns
    -------
    fig : :class:`matplotlib.figure.Figure`

    Examples
    --------

    .. code-block:: python

       >>> from tethne.analyze.corpus import burstness
       >>> fig = plot_burstness(corpus, 'citations', topn=2, perslice=True)
       >>> fig.savefig('~/burstness.png')

    Years prior to the first occurrence of each feature are grayed out. Periods
    in which the feature was bursty are depicted by colored blocks, the opacity
    of which indicates burstness intensity.

    .. figure:: _static/images/burstness.png
       :width: 600
       :align: center