def _autolev(self, z, N):
if self.locator is None:<EOL><INDENT>if self.logscale:<EOL><INDENT>self.locator = ticker.LogLocator()<EOL><DEDENT>else:<EOL><INDENT>self.locator = ticker.MaxNLocator(N+<NUM_LIT:1>)<EOL><DEDENT><DEDENT>self.locator.create_dummy_axis()<EOL>zmax = self.zmax<EOL>zmin = self.zmin<EOL>self.locator.set_bounds(zmin, zmax)<EOL>lev = self.locator()<EOL>zmargin = (zmax - zmin) * <NUM_LIT> <EOL>if zmax >= lev[-<NUM_LIT:1>]:<EOL><INDENT>lev[-<NUM_LIT:1>] += zmargin<EOL><DEDENT>if zmin <= lev[<NUM_LIT:0>]:<EOL><INDENT>if self.logscale:<EOL><INDENT>lev[<NUM_LIT:0>] = <NUM_LIT> * zmin<EOL><DEDENT>else:<EOL><INDENT>lev[<NUM_LIT:0>] -= zmargin<EOL><DEDENT><DEDENT>self._auto = True<EOL>if self.filled:<EOL><INDENT>return lev<EOL><DEDENT>return lev[<NUM_LIT:1>:-<NUM_LIT:1>]<EOL>
Select contour levels to span the data.

We need two more levels for filled contours than for
line contours, because for the latter we need to specify
the lower and upper boundary of each range. For example,
a single contour boundary, say at z = 0, requires only
one contour line, but two filled regions, and therefore
three levels to provide boundaries for both regions.