def multi_event_singlechan(streams, catalog, station, channel,<EOL>clip=<NUM_LIT>, pre_pick=<NUM_LIT>,<EOL>freqmin=False, freqmax=False, realign=False,<EOL>cut=(-<NUM_LIT>, <NUM_LIT>), PWS=False, **kwargs):
import matplotlib.pyplot as plt<EOL>short_cat = Catalog()<EOL>short_streams = []<EOL>for i, event in enumerate(catalog):<EOL><INDENT>event_stachans = [(pick.waveform_id.station_code,<EOL>pick.waveform_id.channel_code)<EOL>for pick in event.picks]<EOL>if (station, channel) in event_stachans:<EOL><INDENT>short_cat.append(event)<EOL>short_streams.append(streams[i])<EOL><DEDENT><DEDENT>if len(short_cat) == <NUM_LIT:0>:<EOL><INDENT>raise IOError('<STR_LIT>' + station + '<STR_LIT:U+0020>' + channel)<EOL><DEDENT>traces = []<EOL>al_traces = []<EOL>al_picks = []<EOL>if isinstance(short_streams, Stream):<EOL><INDENT>short_streams = [short_streams]<EOL><DEDENT>st_list = deepcopy(short_streams)<EOL>print(short_cat)<EOL>for i, event in enumerate(short_cat):<EOL><INDENT>_pick = [pick for pick in event.picks if<EOL>pick.waveform_id.station_code == station and<EOL>pick.waveform_id.channel_code == channel]<EOL>if len(_pick) == <NUM_LIT:0>:<EOL><INDENT>print('<STR_LIT>')<EOL>continue<EOL><DEDENT>else:<EOL><INDENT>_pick = _pick[<NUM_LIT:0>]<EOL><DEDENT>if st_list[i].select(station=station, channel=channel):<EOL><INDENT>tr = st_list[i].select(station=station, channel=channel)[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>' + _pick.waveform_id.station_code)<EOL>continue<EOL><DEDENT>tr.detrend('<STR_LIT>')<EOL>if freqmin:<EOL><INDENT>tr.filter('<STR_LIT>', freqmin=freqmin, freqmax=freqmax)<EOL><DEDENT>if realign:<EOL><INDENT>tr_cut = tr.copy()<EOL>tr_cut.trim(_pick.time + cut[<NUM_LIT:0>],<EOL>_pick.time + cut[<NUM_LIT:1>],<EOL>nearest_sample=False)<EOL>if len(tr_cut.data) <= (<NUM_LIT:0.5> * (cut[<NUM_LIT:1>] - cut[<NUM_LIT:0>]) *<EOL>tr_cut.stats.sampling_rate):<EOL><INDENT>msg = '<STR_LIT>'.join(['<STR_LIT>',<EOL>tr.stats.station,<EOL>'<STR_LIT:.>', tr.stats.channel, '<STR_LIT:\n>',<EOL>'<STR_LIT>',<EOL>str(_pick.time)])<EOL>warnings.warn(msg)<EOL><DEDENT>else:<EOL><INDENT>al_traces.append(tr_cut)<EOL>al_picks.append(_pick)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>tr.trim(_pick.time - pre_pick,<EOL>_pick.time + clip - pre_pick,<EOL>nearest_sample=False)<EOL><DEDENT>if len(tr.data) == <NUM_LIT:0>:<EOL><INDENT>msg = '<STR_LIT>'.join(['<STR_LIT>', tr.stats.station,<EOL>'<STR_LIT:.>', tr.stats.channel, '<STR_LIT:\n>',<EOL>'<STR_LIT>',<EOL>str(event.picks[<NUM_LIT:0>].time)])<EOL>warnings.warn(msg)<EOL>continue<EOL><DEDENT>traces.append(tr)<EOL><DEDENT>if realign:<EOL><INDENT>shift_len = int(<NUM_LIT> * (cut[<NUM_LIT:1>] - cut[<NUM_LIT:0>]) *<EOL>al_traces[<NUM_LIT:0>].stats.sampling_rate)<EOL>shifts = align_traces(al_traces, shift_len)[<NUM_LIT:0>]<EOL>for i in range(len(shifts)):<EOL><INDENT>print('<STR_LIT>' + str(shifts[i]) + '<STR_LIT>')<EOL>_pick.time -= shifts[i]<EOL>traces[i].trim(al_picks[i].time - pre_pick,<EOL>al_picks[i].time + clip - pre_pick,<EOL>nearest_sample=True)<EOL><DEDENT><DEDENT>if PWS:<EOL><INDENT>stack = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>stack = '<STR_LIT>'<EOL><DEDENT>for tr in traces:<EOL><INDENT>print(tr)<EOL><DEDENT>fig = multi_trace_plot(<EOL>traces=traces, corr=True, stack=stack, show=False, return_figure=True)<EOL>plt.subplots_adjust(hspace=<NUM_LIT:0>)<EOL>fig = _finalise_figure(fig=fig, **kwargs)  <EOL>return traces, short_cat, fig<EOL>
Plot data from a single channel for multiple events.

Data will be aligned by their pick-time given in the appropriate picks.
Requires an individual stream for each event you want to plot,
events are stored in the :class:`obspy.core.event.Catalog` object, and
there must be picks present for the streams you wish to plot.  Events will
be aligned if `realign=True`, in this case the traces will be aligned
using the window defined by `cut`.

:type streams: list
:param streams:
    List of the :class:`obspy.core.stream.Stream` objects to use, can
    contain more traces than you plan on plotting (e.g. from more channels)
    - must be in the same order as events in catalog.
:type catalog: obspy.core.event.Catalog
:param catalog: Catalog of events, one for each stream.
:type station: str
:param station: Station to plot.
:type channel: str
:param channel: Channel to plot.
:type clip: float
:param clip: Length in seconds to plot, defaults to 10.0
:type pre_pick: float
:param pre_pick: Length in seconds to extract and plot before the pick, \
    defaults to 2.0
:type freqmin: float
:param freqmin: Low cut for bandpass in Hz
:type freqmax: float
:param freqmax: High cut for bandpass in Hz
:type realign: bool
:param realign:
    To compute best alignment based on correlation with the stack or not.
:type cut: tuple
:param cut: tuple of start and end times for cut in seconds from the \
    pick, used for alignment.  Will only use this window to align the \
    traces.
:type PWS: bool
:param PWS: compute Phase Weighted Stack, if False, will compute linear \
    stack for alignment.

:returns: Aligned and cut :class:`obspy.core.trace.Trace`
:rtype: list
:returns:
    New picks in based on alignment (if alignment is performed, if not
    will return the same as input)
:rtype: :class:`obspy.core.event.Catalog`
:returns: Figure object for further editing
:rtype: :class:`matplotlib.figure.Figure`

.. rubric:: Example

>>> from obspy import read, Catalog, read_events
>>> from obspy.io.nordic.core import readwavename
>>> from eqcorrscan.utils.plotting import multi_event_singlechan
>>> import glob
>>> sfiles = glob.glob('eqcorrscan/tests/test_data/REA/TEST_/*.S??????')
>>> catalog = Catalog()
>>> streams = []
>>> for sfile in sfiles:
...     catalog += read_events(sfile)
...     wavfile = readwavename(sfile)[0]
...     stream_path = 'eqcorrscan/tests/test_data/WAV/TEST_/' + wavfile
...     stream = read(stream_path)
...     # Annoying coping with seisan 2 letter channels
...     for tr in stream:
...         tr.stats.channel = tr.stats.channel[0] + tr.stats.channel[-1]
...     streams.append(stream)
>>> multi_event_singlechan(streams=streams, catalog=catalog,
...                        station='GCSZ', channel='EZ') # doctest: +SKIP

.. image:: ../../plots/multi_event_singlechan.png