def xcorr_plot(template, image, shift=None, cc=None, cc_vec=None, **kwargs):
import matplotlib.pyplot as plt<EOL>if cc is None or shift is None:<EOL><INDENT>if not isinstance(cc_vec, np.ndarray):<EOL><INDENT>print('<STR_LIT>' % (cc, shift))<EOL>raise IOError('<STR_LIT>')<EOL><DEDENT>shift = np.abs(cc_vec).argmax()<EOL>cc = cc_vec[shift]<EOL><DEDENT>x = np.arange(len(image))<EOL>plt.plot(x, image / abs(image).max(), '<STR_LIT:k>', lw=<NUM_LIT>, label='<STR_LIT>')<EOL>x = np.arange(len(template)) + shift<EOL>plt.plot(x, template / abs(template).max(), '<STR_LIT:r>', lw=<NUM_LIT>, label='<STR_LIT>')<EOL>plt.title('<STR_LIT>' % (shift, cc))<EOL>fig = plt.gcf()<EOL>fig = _finalise_figure(fig=fig, **kwargs)  <EOL>return fig<EOL>
Plot a template overlying an image aligned by correlation.

:type template: numpy.ndarray
:param template: Short template image
:type image: numpy.ndarray
:param image: Long master image
:type shift: int
:param shift: Shift to apply to template relative to image, in samples
:type cc: float
:param cc: Cross-correlation at shift
:type cc_vec: numpy.ndarray
:param cc_vec: Cross-correlation vector.
:type save: bool
:param save: Whether to save the plot or not.
:type savefile: str
:param savefile: File name to save to

:returns: :class:`matplotlib.figure.Figure`

.. rubric:: Example

>>> from obspy import read
>>> from eqcorrscan.utils.plotting import xcorr_plot
>>> from eqcorrscan.utils.stacking import align_traces
>>> st = read().detrend('simple').filter('bandpass', freqmin=2, freqmax=15)
>>> shifts, ccs = align_traces([st[0], st[1]], 40)
>>> shift = shifts[1] * st[1].stats.sampling_rate
>>> cc = ccs[1]
>>> xcorr_plot(template=st[1].data, image=st[0].data, shift=shift,
...            cc=cc) # doctest: +SKIP

.. image:: ../../plots/xcorr_plot.png