Example #1
0
    def _set_clip(self):

        if not self._useDataClipping: return
        #self._logcache = None

        try:
            self._xmin, self._xmax
        except AttributeError:
            indx = arange(len(self._x))
        else:
            if not hasattr(self, '_xsorted'):
                self._xsorted = self._is_sorted(self._x)
            if len(self._x) == 1:
                indx = [0]
            elif self._xsorted:
                # for really long signals, if we know they are sorted
                # on x we can save a lot of time using search sorted
                # since the alternative approach requires 3 O(len(x) ) ops
                indMin, indMax = searchsorted(self._x,
                                              array([self._xmin, self._xmax]))
                indMin = max(0, indMin - 1)
                indMax = min(indMax + 1, len(self._x))
                skip = 0
                if self._lod:
                    # if level of detail is on, decimate the data
                    # based on pixel width
                    raise NotImplementedError('LOD deprecated')
                    l, b, w, h = self.get_window_extent().get_bounds()
                    skip = int((indMax - indMin) / w)
                if skip > 0: indx = arange(indMin, indMax, skip)
                else: indx = arange(indMin, indMax)
            else:
                indx = nonzero(
                    logical_and(self._x >= self._xmin, self._x <= self._xmax))

        self._xc = take(self._x, indx)
        self._yc = take(self._y, indx)

        # y data clipping for connected lines can introduce horizontal
        # line artifacts near the clip region.  If you really need y
        # clipping for efficiency, consider using plot(y,x) instead.
        if (self._yc.shape == self._xc.shape and self._linestyle is None):
            try:
                self._ymin, self._ymax
            except AttributeError:
                indy = arange(len(self._yc))
            else:
                indy = nonzero(
                    logical_and(self._yc >= self._ymin,
                                self._yc <= self._ymax))
        else:
            indy = arange(len(self._yc))

        self._xc = take(self._xc, indy)
        self._yc = take(self._yc, indy)
Example #2
0
    def _set_clip(self):

        if not self._useDataClipping:
            return
        # self._logcache = None

        try:
            self._xmin, self._xmax
        except AttributeError:
            indx = arange(len(self._x))
        else:
            if not hasattr(self, "_xsorted"):
                self._xsorted = self._is_sorted(self._x)
            if len(self._x) == 1:
                indx = [0]
            elif self._xsorted:
                # for really long signals, if we know they are sorted
                # on x we can save a lot of time using search sorted
                # since the alternative approach requires 3 O(len(x) ) ops
                indMin, indMax = searchsorted(self._x, array([self._xmin, self._xmax]))
                indMin = max(0, indMin - 1)
                indMax = min(indMax + 1, len(self._x))
                skip = 0
                if self._lod:
                    # if level of detail is on, decimate the data
                    # based on pixel width
                    raise NotImplementedError("LOD deprecated")
                    l, b, w, h = self.get_window_extent().get_bounds()
                    skip = int((indMax - indMin) / w)
                if skip > 0:
                    indx = arange(indMin, indMax, skip)
                else:
                    indx = arange(indMin, indMax)
            else:
                indx = nonzero(logical_and(self._x >= self._xmin, self._x <= self._xmax))

        self._xc = take(self._x, indx)
        self._yc = take(self._y, indx)

        # y data clipping for connected lines can introduce horizontal
        # line artifacts near the clip region.  If you really need y
        # clipping for efficiency, consider using plot(y,x) instead.
        if self._yc.shape == self._xc.shape and self._linestyle is None:
            try:
                self._ymin, self._ymax
            except AttributeError:
                indy = arange(len(self._yc))
            else:
                indy = nonzero(logical_and(self._yc >= self._ymin, self._yc <= self._ymax))
        else:
            indy = arange(len(self._yc))

        self._xc = take(self._xc, indy)
        self._yc = take(self._yc, indy)
Example #3
0
    def _get_plottable(self):
        # If log scale is set, only pos data will be returned

        x, y = self._x, self._y

        try: logx = self._transform.get_funcx().get_type()==LOG10
        except RuntimeError: logx = False  # non-separable

        try: logy = self._transform.get_funcy().get_type()==LOG10
        except RuntimeError: logy = False  # non-separable

        if not logx and not logy:
            return x, y

        if self._logcache is not None:
            waslogx, waslogy, xcache, ycache = self._logcache
            if logx==waslogx and waslogy==logy:
                return xcache, ycache

        Nx = len(x)
        Ny = len(y)

        if logx: indx = greater(x, 0)
        else:    indx = ones(len(x))

        if logy: indy = greater(y, 0)
        else:    indy = ones(len(y))

        ind = nonzero(logical_and(indx, indy))
        x = take(x, ind)
        y = take(y, ind)

        self._logcache = logx, logy, x, y
        return x, y
Example #4
0
    def __call__(self):
        'Return the locations of the ticks'
        self.verify_intervals()
        b=self.base
        subs=self.subs
        vmin, vmax = self.viewInterval.get_bounds()
        vmin = math.log(vmin)/math.log(b)
        vmax = math.log(vmax)/math.log(b)

        if vmax<vmin:
            vmin, vmax = vmax, vmin
        ticklocs = []
        for decadeStart in b**arange(math.floor(vmin),math.ceil(vmax)):
            ticklocs.extend( subs*decadeStart )

        if(len(subs) and subs[0]==1.0):
            ticklocs.append(b**math.ceil(vmax))

            
        ticklocs = array(ticklocs)
        ind = nonzero(logical_and(ticklocs>=b**vmin ,
                                  ticklocs<=b**vmax))

        
        ticklocs = take(ticklocs,ind)
        return ticklocs
Example #5
0
    def __call__(self):
        'Return the locations of the ticks'
        self.verify_intervals()
        b=self._base

        vmin, vmax = self.viewInterval.get_bounds()
        vmin = math.log(vmin)/math.log(b)
        vmax = math.log(vmax)/math.log(b)

        if vmax<vmin:
            vmin, vmax = vmax, vmin
        ticklocs = []

        numdec = math.floor(vmax)-math.ceil(vmin)
        if self._subs is None: # autosub
            if numdec>10: subs = array([1.0])
            elif numdec>6: subs = arange(2.0, b, 2.0)
            else: subs = arange(2.0, b)
        else:
            subs = self._subs
        for decadeStart in b**arange(math.floor(vmin),math.ceil(vmax)):
            ticklocs.extend( subs*decadeStart )

        if(len(subs) and subs[0]==1.0):
            ticklocs.append(b**math.ceil(vmax))


        ticklocs = array(ticklocs)
        ind = nonzero(logical_and(ticklocs>=b**vmin ,
                                  ticklocs<=b**vmax))


        ticklocs = take(ticklocs,ind)
        return ticklocs
Example #6
0
    def __call__(self):
        'Return the locations of the ticks'
        self.verify_intervals()
        b=self.base
        subs=self.subs
        vmin, vmax = self.viewInterval.get_bounds()
        vmin = math.log(vmin)/math.log(b)
        vmax = math.log(vmax)/math.log(b)

        if vmax<vmin:
            vmin, vmax = vmax, vmin
        ticklocs = []
        for decadeStart in b**arange(math.floor(vmin),math.ceil(vmax)):
            ticklocs.extend( subs*decadeStart )

        if(len(subs) and subs[0]==1.0):
            ticklocs.append(b**math.ceil(vmax))

            
        ticklocs = array(ticklocs)
        ind = nonzero(logical_and(ticklocs>=b**vmin ,
                                  ticklocs<=b**vmax))

        
        ticklocs = take(ticklocs,ind)
        return ticklocs
Example #7
0
    def _get_numeric_clipped_data_in_range(self):
        # if the x or y clip is set, only plot the points in the
        # clipping region.  If log scale is set, only pos data will be
        # returned

        try:
            self._xc, self._yc
        except AttributeError:
            x, y = self._x, self._y
        else:
            x, y = self._xc, self._yc

        try:
            logx = self._transform.get_funcx().get_type() == LOG10
        except RuntimeError:
            logx = False  # non-separable

        try:
            logy = self._transform.get_funcy().get_type() == LOG10
        except RuntimeError:
            logy = False  # non-separable

        if not logx and not logy:
            return x, y

        if self._logcache is not None:
            waslogx, waslogy, xcache, ycache = self._logcache
            if logx == waslogx and waslogy == logy:
                return xcache, ycache

        Nx = len(x)
        Ny = len(y)

        if logx:
            indx = greater(x, 0)
        else:
            indx = ones(len(x))

        if logy:
            indy = greater(y, 0)
        else:
            indy = ones(len(y))

        ind = nonzero(logical_and(indx, indy))
        x = take(x, ind)
        y = take(y, ind)

        self._logcache = logx, logy, x, y
        return x, y
Example #8
0
    def _get_numeric_clipped_data_in_range(self):
        # if the x or y clip is set, only plot the points in the
        # clipping region.  If log scale is set, only pos data will be
        # returned

        try:
            self._xc, self._yc
        except AttributeError:
            x, y = self._x, self._y
        else:
            x, y = self._xc, self._yc

        try:
            logx = self._transform.get_funcx().get_type() == LOG10
        except RuntimeError:
            logx = False  # non-separable

        try:
            logy = self._transform.get_funcy().get_type() == LOG10
        except RuntimeError:
            logy = False  # non-separable

        if not logx and not logy:
            return x, y

        if self._logcache is not None:
            waslogx, waslogy, xcache, ycache = self._logcache
            if logx == waslogx and waslogy == logy:
                return xcache, ycache

        Nx = len(x)
        Ny = len(y)

        if logx: indx = greater(x, 0)
        else: indx = ones(len(x))

        if logy: indy = greater(y, 0)
        else: indy = ones(len(y))

        ind = nonzero(logical_and(indx, indy))
        x = take(x, ind)
        y = take(y, ind)

        self._logcache = logx, logy, x, y
        return x, y