def _plot_legend(pos, colors, axis, bads, outlines, loc):
 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=loc)
 (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)

def _plot_legend ( pos , colors , axis , bads , outlines , loc ) : 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 = loc ) ( 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 )
plot color/channel legends for butterfly plots with spatial colors .