def view_limits(self, vmin, vmax):
if vmax<vmin:<EOL><INDENT>vmin, vmax = vmax, vmin<EOL><DEDENT>if vmin==vmax:<EOL><INDENT>vmin-=<NUM_LIT:1><EOL>vmax+=<NUM_LIT:1><EOL><DEDENT>exponent, remainder = divmod(math.log10(vmax - vmin), <NUM_LIT:1>)<EOL>if remainder < <NUM_LIT:0.5>:<EOL><INDENT>exponent -= <NUM_LIT:1><EOL><DEDENT>scale = <NUM_LIT:10>**(-exponent)<EOL>vmin = math.floor(scale*vmin)/scale<EOL>vmax = math.ceil(scale*vmax)/scale<EOL>return mtransforms.nonsingular(vmin, vmax)<EOL>
Try to choose the view limits intelligently