<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def draw_residual(x, y, yerr, xerr, show_errbars=True, ax=None, zero_line=True, grid=True, **kwargs):
 """Draw a residual plot on the axis. By default, if show_errbars if True, residuals are drawn as blue points with errorbars with no endcaps. If show_errbars is False, residuals are drawn as a bar graph with black bars. **Arguments** - **x** array of numbers, x-coordinates - **y** array of numbers, y-coordinates - **yerr** array of numbers, the uncertainty on the y-values - **xerr** array of numbers, the uncertainty on the x-values - **show_errbars** If True, draw the data as a bar plot, else as an errorbar plot - **ax** Optional matplotlib axis instance on which to draw the plot - **zero_line** If True, draw a red line at :math:`y = 0` along the full extent in :math:`x` - **grid** If True, draw gridlines - **kwargs** passed to ``ax.errorbar`` (if ``show_errbars`` is True) or ``ax.bar`` (if ``show_errbars`` if False) **Returns** The matplotlib axis instance the plot was drawn on. """

    from matplotlib import pyplot as plt

    ax = plt.gca() if ax is None else ax

    if show_errbars:
        plotopts = dict(fmt='b.', capsize=0)
        plotopts.update(kwargs)
        pp = ax.errorbar(x, y, yerr, xerr, zorder=0, **plotopts)
    else:
        plotopts = dict(color='k')
        plotopts.update(kwargs)
        pp = ax.bar(x - xerr, y, width=2*xerr, **plotopts)

    if zero_line:
        ax.plot([x[0] - xerr[0], x[-1] + xerr[-1]], [0, 0], 'r-', zorder=2)

    # Take the `grid` kwarg to mean 'add a grid if True'; if grid is False and
    # we called ax.grid(False) then any existing grid on ax would be turned off
    if grid:
        ax.grid(grid)

    return ax