Пример #1
0
    def _autolev(self, z, N):
        '''
        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.
        '''
        zmax = self.zmax
        zmin = self.zmin
        zmargin = (zmax - zmin) * 0.001  # so z < (zmax + zmargin)
        zmax = zmax + zmargin
        intv = Interval(Value(zmin), Value(zmax))
        if self.locator is None:
            self.locator = MaxNLocator(N + 1)
        self.locator.set_view_interval(intv)
        self.locator.set_data_interval(intv)
        lev = self.locator()
        self._auto = True
        if self.filled:
            return lev
        return lev[1:-1]