

def _plot_legend(pos, colors, axis, bads, outlines):
    'Helper function to plot color/channel legends for butterfly plots\n    with spatial colors'
    from mpl_toolkits.axes_grid.inset_locator import inset_axes
    bbox = axis.get_window_extent()
    ratio = (bbox.width / bbox.height)
    ax = inset_axes(axis, width=(str((30 / ratio)) + '%'), height='30%', loc=2)
    (pos_x, pos_y) = _prepare_topomap(pos, ax)
    ax.scatter(pos_x, pos_y, color=colors, s=25, marker='.', zorder=1)
    for idx in bads:
        ax.scatter(pos_x[idx], pos_y[idx], s=5, marker='.', color='w', zorder=1)
    if isinstance(outlines, dict):
        _draw_outlines(ax, outlines)

dataset/ETHPy150Open mne-tools/mne-python/mne/viz/evoked.py _plot_legend/original