

def plot_evoked_joint(evoked, times='peaks', title='', picks=None, exclude=None, show=True, ts_args=None, topomap_args=None):
    'Plot evoked data as butterfly plot and add topomaps for selected\n    time points.\n\n    Parameters\n    ----------\n    evoked : instance of Evoked\n        The evoked instance.\n    times : float | array of floats | "auto" | "peaks".\n        The time point(s) to plot. If "auto", 5 evenly spaced topographies\n        between the first and last time instant will be shown. If "peaks",\n        finds time points automatically by checking for 3 local maxima in\n        Global Field Power. Defaults to "peaks".\n    title : str | None\n        The title. If `None`, suppress printing channel type. Defaults to \'\'.\n    picks : array-like of int | None\n        The indices of channels to plot. If None show all. Defaults to None.\n    exclude : None | list of str | \'bads\'\n        Channels names to exclude from being shown. If \'bads\', the\n        bad channels are excluded. Defaults to None.\n    show : bool\n        Show figure if True. Defaults to True.\n    ts_args : None | dict\n        A dict of `kwargs` that are forwarded to `evoked.plot` to\n        style the butterfly plot. `axes` and `show` are ignored.\n        If `spatial_colors` is not in this dict, `spatial_colors=True`\n        will be passed. Beyond that, if ``None``, no customizable arguments\n        will be passed. Defaults to ``None``.\n    topomap_args : None | dict\n        A dict of `kwargs` that are forwarded to `evoked.plot_topomap`\n        to style the topomaps. `axes` and `show` are ignored. If `times`\n        is not in this dict, automatic peak detection is used. Beyond that,\n        if ``None`, no customizable arguments will be passed.\n        Defaults to ``None``.\n\n    Returns\n    -------\n    fig : instance of matplotlib.figure.Figure | list\n        The figure object containing the plot. If `evoked` has multiple\n        channel types, a list of figures, one for each channel type, is\n        returned.\n\n    Notes\n    -----\n    .. versionadded:: 0.12.0\n    '
    import matplotlib.pyplot as plt
    if (ts_args is None):
        ts_args = dict()
    if (topomap_args is None):
        topomap_args = dict()
    evoked = evoked.copy()
    if (picks is not None):
        pick_names = [evoked.info['ch_names'][pick] for pick in picks]
    else:
        picks = _pick_data_channels(evoked.info, exclude=[])
        pick_names = [evoked.info['ch_names'][pick] for pick in picks]
    evoked.pick_channels(pick_names)
    if (exclude == 'bads'):
        exclude = [ch for ch in evoked.info['bads'] if (ch in evoked.info['ch_names'])]
    if (exclude is not None):
        evoked.drop_channels(exclude)
    info = evoked.info
    data_types = ['eeg', 'grad', 'mag', 'seeg', 'ecog']
    ch_types = set((ch_type for ch_type in data_types if (ch_type in evoked)))
    if (len(ch_types) > 1):
        figs = list()
        for t in ch_types:
            ev_ = evoked.copy().pick_channels([info['ch_names'][idx] for idx in range(info['nchan']) if (channel_type(info, idx) == t)])
            if (len(set([channel_type(ev_.info, idx) for idx in range(ev_.info['nchan']) if (channel_type(ev_.info, idx) in data_types)])) > 1):
                raise RuntimeError('Possibly infinite loop due to channel selection problem. This should never happen! Please check your channel types.')
            figs.append(plot_evoked_joint(ev_, times=times, title=title, show=show, ts_args=ts_args, exclude=list(), topomap_args=topomap_args))
        return figs
    fig = plt.figure(figsize=(8.0, 4.2))
    times = _process_times(evoked, times, few=True)
    ts_ax = fig.add_subplot(212)
    ts_args_pass = dict(((k, v) for (k, v) in ts_args.items() if (k not in ['axes', 'show', 'colorbar', 'set_tight_layout'])))
    ts_args_def = dict(picks=None, unit=True, ylim=None, xlim='tight', proj=False, hline=None, units=None, scalings=None, titles=None, gfp=False, window_title=None, spatial_colors=True)
    for key in ts_args_def:
        if (key not in ts_args):
            ts_args_pass[key] = ts_args_def[key]
    _plot_evoked(evoked, axes=ts_ax, show=False, plot_type='butterfly', exclude=[], set_tight_layout=False, **ts_args_pass)
    old_title = ts_ax.get_title()
    ts_ax.set_title('')
    if (title is not None):
        title_ax = plt.subplot(4, 3, 2)
        title = (', '.join([title, old_title]) if (len(title) > 0) else old_title)
        title_ax.text(0.5, 0.5, title, transform=title_ax.transAxes, horizontalalignment='center', verticalalignment='center')
        title_ax.axis('off')
    ts = (len(times) + 2)
    map_ax = [plt.subplot(4, ts, ((x + 2) + ts)) for x in range((ts - 2))]
    cbar_ax = plt.subplot(4, (3 * (ts + 1)), (6 * (ts + 1)))
    topomap_args_pass = dict(((k, v) for (k, v) in topomap_args.items() if (k not in ['times', 'axes', 'show', 'colorbar'])))
    topomap_args_pass['outlines'] = (topomap_args['outlines'] if ('outlines' in topomap_args) else 'skirt')
    evoked.plot_topomap(times=times, axes=map_ax, show=False, colorbar=False, **topomap_args_pass)
    if topomap_args.get('colorbar', True):
        from matplotlib import ticker
        cbar = plt.colorbar(map_ax[0].images[0], cax=cbar_ax)
        cbar.locator = ticker.MaxNLocator(nbins=5)
        cbar.update_ticks()
    plt.subplots_adjust(left=0.1, right=0.93, bottom=0.14, top=(1.0 if (title is not None) else 1.2))
    tstimes = [(timepoint * 1000.0) for timepoint in times]
    lines = [_connection_line(timepoint, fig, ts_ax, map_ax_) for (timepoint, map_ax_) in zip(tstimes, map_ax)]
    for line in lines:
        fig.lines.append(line)
    for timepoint in tstimes:
        ts_ax.axvline(timepoint, color='grey', linestyle='-', linewidth=1.5, alpha=0.66, zorder=0)
    plt_show(show)
    return fig

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