def trim(xmin="<STR_LIT>", xmax="<STR_LIT>", ymin="<STR_LIT>", ymax="<STR_LIT>", axes="<STR_LIT>"):
if axes=="<STR_LIT>": axes = _pylab.gca()<EOL>if xmin=="<STR_LIT>": (xmin, dummy) = axes.get_xlim()<EOL>if xmax=="<STR_LIT>": (dummy, xmax) = axes.get_xlim()<EOL>if ymin=="<STR_LIT>": (ymin, dummy) = axes.get_ylim()<EOL>if ymax=="<STR_LIT>": (dummy, ymax) = axes.get_ylim()<EOL>lines = axes.get_lines()<EOL>for line in lines:<EOL><INDENT>old_xdata = line.get_xdata()<EOL>old_ydata = line.get_ydata()<EOL>new_xdata = []<EOL>new_ydata = []<EOL>for n in range(<NUM_LIT:0>, len(old_xdata)):<EOL><INDENT>if  old_xdata[n] >= xmin and old_xdata[n] <= xmaxand old_ydata[n] >= ymin and old_ydata[n] <= ymax:<EOL><INDENT>new_xdata.append(old_xdata[n])<EOL>new_ydata.append(old_ydata[n])<EOL><DEDENT><DEDENT>if len(new_xdata) == <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>"+str(line)+"<STR_LIT:!>")<EOL><DEDENT>else:<EOL><INDENT>line.set_data(new_xdata, new_ydata)<EOL><DEDENT><DEDENT>for c in axes.collections:<EOL><INDENT>for n in range(len(c._paths)-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>naughty = False<EOL>for v in c._paths[n].vertices:<EOL><INDENT>if v[<NUM_LIT:0>] < xmin or v[<NUM_LIT:0>] > xmax or v[<NUM_LIT:1>] < ymin or v[<NUM_LIT:1>] > ymax:<EOL><INDENT>naughty=True<EOL><DEDENT><DEDENT>if naughty: c._paths.pop(n)<EOL><DEDENT><DEDENT>auto_zoom()<EOL>
This function just removes all data from the plots that
is outside of the [xmin,xmax,ymin,ymax] range.

"auto" means "determine from the current axes's range"