def ticks(self,m=10): start = self._domain[0] end = self._domain[-1] reverse = end < start _min = float(end if reverse else start) _max = float(start if reverse else end) span = _max - _min # test special degenerate cases if span == 0 or math.isinf(span): return _min step = pv.logFloor(span / m, 10) err = m / (span / step) if err <= 0.15: step *= 5 if err <= 0.75: step *= 2 start = math.ceil(_min / step) * step end = math.floor(_min / step) * step self._tickFormat = pv.Format.number().fractionDigits( max(0, math.floor(pv.log(step,10) + 0.01)) ) ticks = range(start, end + step, step) return reversed(ticks) if reverse else ticks
def nice(self): domain = self.domain() self.domain( pv.logFloor(domain[0],self._base), pv.logCeil(domain[1],self_base) ) return self