def auto_zoom(zoomx=True, zoomy=True, axes="<STR_LIT>", x_space=<NUM_LIT>, y_space=<NUM_LIT>, draw=True):
<EOL>_pylab.ioff()<EOL>if axes=="<STR_LIT>": axes = _pylab.gca()<EOL>x10, x20 = axes.get_xlim()<EOL>y10, y20 = axes.get_ylim()<EOL>axes.autoscale(enable=True, tight=True)<EOL>if axes.get_xscale() == '<STR_LIT>':<EOL><INDENT>x1, x2 = axes.get_xlim()<EOL>xc = <NUM_LIT:0.5>*(x1+x2)<EOL>xs = <NUM_LIT:0.5>*(<NUM_LIT:1>+x_space)*(x2-x1)<EOL>axes.set_xlim(xc-xs, xc+xs)<EOL><DEDENT>if axes.get_yscale() == '<STR_LIT>':<EOL><INDENT>y1, y2 = axes.get_ylim()<EOL>yc = <NUM_LIT:0.5>*(y1+y2)<EOL>ys = <NUM_LIT:0.5>*(<NUM_LIT:1>+y_space)*(y2-y1)<EOL>axes.set_ylim(yc-ys, yc+ys)<EOL><DEDENT>if not zoomx: axes.set_xlim(x10, x20)<EOL>if not zoomy: axes.set_ylim(y10, y20)<EOL>if draw: <EOL><INDENT>_pylab.ion()<EOL>_pylab.draw()<EOL><DEDENT>
Looks at the bounds of the plotted data and zooms accordingly, leaving some
space around the data.