def plot_repicked(template, picks, det_stream, size=(<NUM_LIT>, <NUM_LIT>), **kwargs):
import matplotlib.pyplot as plt<EOL>fig, axes = plt.subplots(len(template), <NUM_LIT:1>, sharex=True, figsize=size)<EOL>if len(template) > <NUM_LIT:1>:<EOL><INDENT>axes = axes.ravel()<EOL><DEDENT>mintime = det_stream.sort(['<STR_LIT>'])[<NUM_LIT:0>].stats.starttime<EOL>template.sort(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>lengths = []<EOL>lines = []<EOL>labels = []<EOL>n_templates_plotted = <NUM_LIT:0><EOL>for i, tr in enumerate(template.sort(['<STR_LIT>'])):<EOL><INDENT>if len(template) > <NUM_LIT:1>:<EOL><INDENT>axis = axes[i]<EOL><DEDENT>else:<EOL><INDENT>axis = axes<EOL><DEDENT>tr_picks = [pick for pick in picks if<EOL>pick.waveform_id.station_code == tr.stats.station and<EOL>pick.waveform_id.channel_code[<NUM_LIT:0>] +<EOL>pick.waveform_id.channel_code[-<NUM_LIT:1>] ==<EOL>tr.stats.channel[<NUM_LIT:0>] + tr.stats.channel[-<NUM_LIT:1>]]<EOL>if len(tr_picks) > <NUM_LIT:1>:<EOL><INDENT>msg = '<STR_LIT>' % tr.stats.station + '<STR_LIT:U+002CU+0020>' +tr.stats.channel<EOL>raise NotImplementedError(msg)<EOL><DEDENT>if len(tr_picks) == <NUM_LIT:0>:<EOL><INDENT>msg = '<STR_LIT>' % tr.stats.station + '<STR_LIT:U+002CU+0020>' +tr.stats.channel<EOL>print(msg)<EOL><DEDENT>else:<EOL><INDENT>pick = tr_picks[<NUM_LIT:0>]<EOL>delay = pick.time - mintime<EOL>y = tr.data<EOL>y = y / max(y)<EOL>x = np.linspace(<NUM_LIT:0>, (len(y) - <NUM_LIT:1>) * tr.stats.delta, len(y))<EOL>x += delay<EOL><DEDENT>btr = det_stream.select(station=tr.stats.station,<EOL>channel=tr.stats.channel)[<NUM_LIT:0>]<EOL>bdelay = btr.stats.starttime - mintime<EOL>by = btr.data<EOL>if len(tr_picks) > <NUM_LIT:0>:<EOL><INDENT>by = by / max(by[int((delay - bdelay) * btr.stats.sampling_rate):<EOL>int((delay - bdelay) * btr.stats.sampling_rate) +<EOL>len(x)])<EOL><DEDENT>else:<EOL><INDENT>by = by / max(by)<EOL><DEDENT>bx = np.linspace(<NUM_LIT:0>, (len(by) - <NUM_LIT:1>) * btr.stats.delta, len(by))<EOL>bx += bdelay<EOL>axis.plot(bx, by, '<STR_LIT:k>', linewidth=<NUM_LIT>)<EOL>if len(tr_picks) > <NUM_LIT:0>:<EOL><INDENT>template_line, = axis.plot(x, y, '<STR_LIT:r>', linewidth=<NUM_LIT>,<EOL>label='<STR_LIT>')<EOL>if not pick.phase_hint:<EOL><INDENT>pcolor = '<STR_LIT:k>'<EOL>label = '<STR_LIT>'<EOL><DEDENT>elif '<STR_LIT:P>' in pick.phase_hint.upper():<EOL><INDENT>pcolor = '<STR_LIT>'<EOL>label = '<STR_LIT>'<EOL><DEDENT>elif '<STR_LIT:S>' in pick.phase_hint.upper():<EOL><INDENT>pcolor = '<STR_LIT>'<EOL>label = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>pcolor = '<STR_LIT:k>'<EOL>label = '<STR_LIT>'<EOL><DEDENT>pdelay = pick.time - mintime<EOL>line = axis.axvline(x=pdelay, color=pcolor, linewidth=<NUM_LIT:2>,<EOL>linestyle='<STR_LIT>', label=label)<EOL>if label not in labels:<EOL><INDENT>lines.append(line)<EOL>labels.append(label)<EOL><DEDENT>if n_templates_plotted == <NUM_LIT:0>:<EOL><INDENT>lines.append(template_line)<EOL>labels.append('<STR_LIT>')<EOL><DEDENT>n_templates_plotted += <NUM_LIT:1><EOL>lengths.append(max(bx[-<NUM_LIT:1>], x[-<NUM_LIT:1>]))<EOL><DEDENT>else:<EOL><INDENT>lengths.append(bx[<NUM_LIT:1>])<EOL><DEDENT>axis.set_ylabel('<STR_LIT:.>'.join([tr.stats.station, tr.stats.channel]),<EOL>rotation=<NUM_LIT:0>, horizontalalignment='<STR_LIT:right>')<EOL>axis.yaxis.set_ticks([])<EOL><DEDENT>axis.set_xlim([<NUM_LIT:0>, max(lengths)])<EOL>if len(template) > <NUM_LIT:1>:<EOL><INDENT>axis = axes[len(template) - <NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>axis = axes<EOL><DEDENT>axis.set_xlabel('<STR_LIT>' %<EOL>mintime.datetime.strftime('<STR_LIT>'))<EOL>plt.figlegend(lines, labels, '<STR_LIT>')<EOL>title = kwargs.get("<STR_LIT:title>") or None<EOL>if title:<EOL><INDENT>if len(template) > <NUM_LIT:1>:<EOL><INDENT>axes[<NUM_LIT:0>].set_title(title)<EOL><DEDENT>else:<EOL><INDENT>axes.set_title(title)<EOL><DEDENT>kwargs.pop("<STR_LIT:title>")<EOL><DEDENT>else:<EOL><INDENT>plt.subplots_adjust(top=<NUM_LIT>)<EOL><DEDENT>plt.tight_layout()<EOL>plt.subplots_adjust(hspace=<NUM_LIT:0>)<EOL>fig = _finalise_figure(fig=fig, **kwargs)  <EOL>return fig<EOL>
Plot a template over a detected stream, with picks corrected by lag-calc.

:type template: obspy.core.stream.Stream
:param template: Template used to make the detection, will be aligned \
    according to picks.
:param picks:
    list of corrected picks, each pick must be an
    :class:`obspy.core.event.origin.Pick` object.
:type picks: list
:param det_stream: Stream to plot in the background, should be the \
    detection, data should encompass the time the picks are made.
:type det_stream: obspy.core.stream.Stream
:param size: Plot size.

:return: Figure handle which can be edited.
:rtype: :class:`matplotlib.figure.Figure`

.. image:: ../../plots/plot_repicked.png