def rasterplot(channels, axes, title, unit, channel_labels=True,
               spike_count=True):
    """
    Produce a raster plot of a spike train on a set of axes.

    Parameters
    ----------
    channels : dict
        A dictionary of spike trains. Keys are channel labels, values are
        lists of spikes.
    axes : matplotlib.axes.Axes
        Set of axes to plot on.
    title : str
        Figure title.
    unit : str
        Units of time to include on x-axis.
    channel_labels : bool
        Whether or not to include y-axis labels.
    spike_count : bool
        Whether or not to include the number of spikes in the x-axis
        label.

    Returns
    -------
    Dictionary mapping channels to offsets on y axis or None.

    """
    if not channels:
        axes.set_xlim((0, 2))
        axes.set_ylim((0, 2))
        axes.set_axis_off()
        axes.set_title(title)
        axes.text(1, 1, "no spikes", ha="center")
        return

    labels = sorted(list(channels.keys()))

    events, nspikes = [], 0
    for label in labels:
        events.append(channels[label].base)
        nspikes += len(channels[label])

    y_offsets = list(range(len(labels)))
    axes.eventplot(events,
                   linelengths=0.75,
                   lineoffsets=y_offsets,
                   color="black",
                   lw=0.2)
    if channel_labels:
        axes.set_yticks(y_offsets)
        axes.set_yticklabels(labels)
        if spike_count:
            xlabel = "time / " + unit + "\n" + "#spikes = " + str(nspikes)
        else:
            xlabel = "time / " + unit
        axes.set_xlabel(xlabel)
        axes.set_ylabel("channel")
    else:
        axes.set_axis_off()
    axes.set_title(title)

    y_offsets_map = dict(zip(labels, y_offsets))
    return y_offsets_map