def smooth_line(line, smoothing=1, trim=True, draw=True):
    """

    This takes a line instance and smooths its data with nearest neighbor averaging.

    """

    # get the actual data values
    xdata = list(line.get_xdata())
    ydata = list(line.get_ydata())

    _fun.smooth_array(ydata, smoothing)

    if trim:
        for n in range(0, smoothing):
            xdata.pop(0); xdata.pop(-1)
            ydata.pop(0); ydata.pop(-1)

    # don't do anything if we don't have any data left
    if len(ydata) == 0:
        print("There's nothing left in "+str(line)+"!")
    else:
        # otherwise set the data with the new arrays
        line.set_data(xdata, ydata)

    # we refresh in real time for giggles
    if draw: _pylab.draw()
def smooth_line ( line , smoothing = 1 , trim = True , draw = True ) : xdata = list ( line . get_xdata ( ) ) ydata = list ( line . get_ydata ( ) ) _fun . smooth_array ( ydata , smoothing ) if trim : for n in range ( 0 , smoothing ) : xdata . pop ( 0 ) ; xdata . pop ( - 1 ) ydata . pop ( 0 ) ; ydata . pop ( - 1 ) if len ( ydata ) == 0 : print ( "There's nothing left in " + str ( line ) + "!" ) else : line . set_data ( xdata , ydata ) if draw : _pylab . draw ( )
This takes a line instance and smooths its data with nearest neighbor averaging.