Python matplotlib.transforms.nonsingular() Examples
The following are 30
code examples of matplotlib.transforms.nonsingular().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.transforms
, or try the search function
.
Example #1
Source File: ticker.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def pan(self, numsteps): """Pan numticks (can be positive or negative)""" ticks = self() numticks = len(ticks) vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) if numticks > 2: step = numsteps * abs(ticks[0] - ticks[1]) else: d = abs(vmax - vmin) step = numsteps * d / 6. vmin += step vmax += step self.axis.set_view_interval(vmin, vmax, ignore=True)
Example #2
Source File: ticker.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def __call__(self, x, pos=None): """ Return the format for tick val *x*. """ if x == 0.0: # Symlog return '0' x = abs(x) b = self._base # only label the decades fx = math.log(x) / math.log(b) is_x_decade = is_close_to_int(fx) exponent = np.round(fx) if is_x_decade else np.floor(fx) coeff = np.round(x / b ** exponent) if self.labelOnlyBase and not is_x_decade: return '' if self._sublabels is not None and coeff not in self._sublabels: return '' vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) s = self._num_to_string(x, vmin, vmax) return self.fix_minus(s)
Example #3
Source File: ticker.py From Computable with MIT License | 6 votes |
def pan(self, numsteps): """Pan numticks (can be positive or negative)""" ticks = self() numticks = len(ticks) vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) if numticks > 2: step = numsteps * abs(ticks[0] - ticks[1]) else: d = abs(vmax - vmin) step = numsteps * d / 6. vmin += step vmax += step self.axis.set_view_interval(vmin, vmax, ignore=True)
Example #4
Source File: ticker.py From Computable with MIT License | 6 votes |
def scale_range(vmin, vmax, n=1, threshold=100): dv = abs(vmax - vmin) if dv == 0: # maxabsv == 0 is a special case of this. return 1.0, 0.0 # Note: this should never occur because # vmin, vmax should have been checked by nonsingular(), # and spread apart if necessary. meanv = 0.5 * (vmax + vmin) if abs(meanv) / dv < threshold: offset = 0 elif meanv > 0: ex = divmod(math.log10(meanv), 1)[0] offset = 10 ** ex else: ex = divmod(math.log10(-meanv), 1)[0] offset = -10 ** ex ex = divmod(math.log10(dv / n), 1)[0] scale = 10 ** ex return scale, offset
Example #5
Source File: converter.py From Computable with MIT License | 6 votes |
def autoscale(self): """ Sets the view limits to the nearest multiples of base that contain the data. """ # requires matplotlib >= 0.98.0 (vmin, vmax) = self.axis.get_data_interval() locs = self._get_default_locs(vmin, vmax) (vmin, vmax) = locs[[0, -1]] if vmin == vmax: vmin -= 1 vmax += 1 return nonsingular(vmin, vmax) #####------------------------------------------------------------------------- #---- --- Formatter --- #####-------------------------------------------------------------------------
Example #6
Source File: ticker.py From Computable with MIT License | 6 votes |
def tick_values(self, vmin, vmax): vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) if vmax < vmin: vmin, vmax = vmax, vmin if (vmin, vmax) in self.presets: return self.presets[(vmin, vmax)] if self.numticks is None: self._set_numticks() if self.numticks == 0: return [] ticklocs = np.linspace(vmin, vmax, self.numticks) return self.raise_if_exceeds(ticklocs)
Example #7
Source File: _converter.py From vnpy_crypto with MIT License | 6 votes |
def autoscale(self): """ Sets the view limits to the nearest multiples of base that contain the data. """ # requires matplotlib >= 0.98.0 (vmin, vmax) = self.axis.get_data_interval() locs = self._get_default_locs(vmin, vmax) (vmin, vmax) = locs[[0, -1]] if vmin == vmax: vmin -= 1 vmax += 1 return nonsingular(vmin, vmax) # ------------------------------------------------------------------------- # --- Formatter --- # -------------------------------------------------------------------------
Example #8
Source File: _converter.py From recruit with Apache License 2.0 | 6 votes |
def autoscale(self): """ Sets the view limits to the nearest multiples of base that contain the data. """ # requires matplotlib >= 0.98.0 (vmin, vmax) = self.axis.get_data_interval() locs = self._get_default_locs(vmin, vmax) (vmin, vmax) = locs[[0, -1]] if vmin == vmax: vmin -= 1 vmax += 1 return nonsingular(vmin, vmax) # ------------------------------------------------------------------------- # --- Formatter --- # -------------------------------------------------------------------------
Example #9
Source File: ticker.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def pan(self, numsteps): """Pan numticks (can be positive or negative)""" ticks = self() numticks = len(ticks) vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) if numticks > 2: step = numsteps * abs(ticks[0] - ticks[1]) else: d = abs(vmax - vmin) step = numsteps * d / 6. vmin += step vmax += step self.axis.set_view_interval(vmin, vmax, ignore=True)
Example #10
Source File: ticker.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def view_limits(self, vmin, vmax): 'Try to choose the view limits intelligently' if vmax < vmin: vmin, vmax = vmax, vmin if vmin == vmax: vmin -= 1 vmax += 1 if rcParams['axes.autolimit_mode'] == 'round_numbers': exponent, remainder = divmod( math.log10(vmax - vmin), math.log10(max(self.numticks - 1, 1))) exponent -= (remainder < .5) scale = max(self.numticks - 1, 1) ** (-exponent) vmin = math.floor(scale * vmin) / scale vmax = math.ceil(scale * vmax) / scale return mtransforms.nonsingular(vmin, vmax)
Example #11
Source File: ticker.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def view_limits(self, dmin, dmax): """ Set the view limits to the nearest multiples of base that contain the data. """ if rcParams['axes.autolimit_mode'] == 'round_numbers': vmin = self._edge.le(dmin) * self._edge.step vmax = self._edge.ge(dmax) * self._edge.step if vmin == vmax: vmin -= 1 vmax += 1 else: vmin = dmin vmax = dmax return mtransforms.nonsingular(vmin, vmax)
Example #12
Source File: ticker.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def tick_values(self, vmin, vmax): if self._symmetric: vmax = max(abs(vmin), abs(vmax)) vmin = -vmax vmin, vmax = mtransforms.nonsingular( vmin, vmax, expander=1e-13, tiny=1e-14) locs = self._raw_ticks(vmin, vmax) prune = self._prune if prune == 'lower': locs = locs[1:] elif prune == 'upper': locs = locs[:-1] elif prune == 'both': locs = locs[1:-1] return self.raise_if_exceeds(locs)
Example #13
Source File: ticker.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def nonsingular(self, vmin, vmax): if not np.isfinite(vmin) or not np.isfinite(vmax): return 1, 10 # initial range, no data plotted yet if vmin > vmax: vmin, vmax = vmax, vmin if vmax <= 0: cbook._warn_external( "Data has no positive values, and therefore cannot be " "log-scaled.") return 1, 10 minpos = self.axis.get_minpos() if not np.isfinite(minpos): minpos = 1e-300 # This should never take effect. if vmin <= 0: vmin = minpos if vmin == vmax: vmin = _decade_less(vmin, self._base) vmax = _decade_greater(vmax, self._base) return vmin, vmax
Example #14
Source File: ticker.py From matplotlib-4-abaqus with MIT License | 6 votes |
def pan(self, numsteps): """Pan numticks (can be positive or negative)""" ticks = self() numticks = len(ticks) vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) if numticks > 2: step = numsteps * abs(ticks[0] - ticks[1]) else: d = abs(vmax - vmin) step = numsteps * d / 6. vmin += step vmax += step self.axis.set_view_interval(vmin, vmax, ignore=True)
Example #15
Source File: ticker.py From matplotlib-4-abaqus with MIT License | 6 votes |
def tick_values(self, vmin, vmax): vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) if vmax < vmin: vmin, vmax = vmax, vmin if (vmin, vmax) in self.presets: return self.presets[(vmin, vmax)] if self.numticks is None: self._set_numticks() if self.numticks == 0: return [] ticklocs = np.linspace(vmin, vmax, self.numticks) return self.raise_if_exceeds(ticklocs)
Example #16
Source File: ticker.py From neural-network-animation with MIT License | 6 votes |
def __call__(self, x, pos=None): """Return the format for tick val *x* at position *pos*""" vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) d = abs(vmax - vmin) b = self._base if x == 0: return '0' sign = np.sign(x) # only label the decades fx = math.log(abs(x)) / math.log(b) isDecade = is_close_to_int(fx) if not isDecade and self.labelOnlyBase: s = '' elif abs(fx) > 10000: s = '%1.0g' % fx elif abs(fx) < 1: s = '%1.0g' % fx else: s = self.pprint_val(fx, d) if sign == -1: s = '-%s' % s return self.fix_minus(s)
Example #17
Source File: ticker.py From neural-network-animation with MIT License | 6 votes |
def pan(self, numsteps): """Pan numticks (can be positive or negative)""" ticks = self() numticks = len(ticks) vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) if numticks > 2: step = numsteps * abs(ticks[0] - ticks[1]) else: d = abs(vmax - vmin) step = numsteps * d / 6. vmin += step vmax += step self.axis.set_view_interval(vmin, vmax, ignore=True)
Example #18
Source File: ticker.py From neural-network-animation with MIT License | 6 votes |
def tick_values(self, vmin, vmax): vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) if vmax < vmin: vmin, vmax = vmax, vmin if (vmin, vmax) in self.presets: return self.presets[(vmin, vmax)] if self.numticks is None: self._set_numticks() if self.numticks == 0: return [] ticklocs = np.linspace(vmin, vmax, self.numticks) return self.raise_if_exceeds(ticklocs)
Example #19
Source File: ticker.py From neural-network-animation with MIT License | 6 votes |
def scale_range(vmin, vmax, n=1, threshold=100): dv = abs(vmax - vmin) if dv == 0: # maxabsv == 0 is a special case of this. return 1.0, 0.0 # Note: this should never occur because # vmin, vmax should have been checked by nonsingular(), # and spread apart if necessary. meanv = 0.5 * (vmax + vmin) if abs(meanv) / dv < threshold: offset = 0 elif meanv > 0: ex = divmod(math.log10(meanv), 1)[0] offset = 10 ** ex else: ex = divmod(math.log10(-meanv), 1)[0] offset = -10 ** ex ex = divmod(math.log10(dv / n), 1)[0] scale = 10 ** ex return scale, offset
Example #20
Source File: ticker.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def __call__(self, x, pos=None): """ Return the format for tick val *x*. """ if x == 0.0: # Symlog return '0' x = abs(x) b = self._base # only label the decades fx = math.log(x) / math.log(b) is_x_decade = is_close_to_int(fx) exponent = np.round(fx) if is_x_decade else np.floor(fx) coeff = np.round(x / b ** exponent) if self.labelOnlyBase and not is_x_decade: return '' if self._sublabels is not None and coeff not in self._sublabels: return '' vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) s = self._num_to_string(x, vmin, vmax) return self.fix_minus(s)
Example #21
Source File: ticker.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def pan(self, numsteps): """Pan numticks (can be positive or negative)""" ticks = self() numticks = len(ticks) vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) if numticks > 2: step = numsteps * abs(ticks[0] - ticks[1]) else: d = abs(vmax - vmin) step = numsteps * d / 6. vmin += step vmax += step self.axis.set_view_interval(vmin, vmax, ignore=True)
Example #22
Source File: ticker.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def tick_values(self, vmin, vmax): vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) if vmax < vmin: vmin, vmax = vmax, vmin if (vmin, vmax) in self.presets: return self.presets[(vmin, vmax)] if self.numticks is None: self._set_numticks() if self.numticks == 0: return [] ticklocs = np.linspace(vmin, vmax, self.numticks) return self.raise_if_exceeds(ticklocs)
Example #23
Source File: ticker.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def view_limits(self, dmin, dmax): """ Set the view limits to the nearest multiples of base that contain the data. """ if rcParams['axes.autolimit_mode'] == 'round_numbers': vmin = self._edge.le(dmin) * self._edge.step vmax = self._base.ge(dmax) * self._edge.step if vmin == vmax: vmin -= 1 vmax += 1 else: vmin = dmin vmax = dmax return mtransforms.nonsingular(vmin, vmax)
Example #24
Source File: ticker.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def tick_values(self, vmin, vmax): if self._symmetric: vmax = max(abs(vmin), abs(vmax)) vmin = -vmax vmin, vmax = mtransforms.nonsingular( vmin, vmax, expander=1e-13, tiny=1e-14) locs = self._raw_ticks(vmin, vmax) prune = self._prune if prune == 'lower': locs = locs[1:] elif prune == 'upper': locs = locs[:-1] elif prune == 'both': locs = locs[1:-1] return self.raise_if_exceeds(locs)
Example #25
Source File: ticker.py From GraphicDesignPatternByPython with MIT License | 6 votes |
def view_limits(self, vmin, vmax): 'Try to choose the view limits intelligently' b = self._base vmin, vmax = self.nonsingular(vmin, vmax) if self.axis.axes.name == 'polar': vmax = math.ceil(math.log(vmax) / math.log(b)) vmin = b ** (vmax - self.numdecs) if rcParams['axes.autolimit_mode'] == 'round_numbers': if not is_decade(vmin, self._base): vmin = decade_down(vmin, self._base) if not is_decade(vmax, self._base): vmax = decade_up(vmax, self._base) return vmin, vmax
Example #26
Source File: ticker.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __call__(self, x, pos=None): """ Return the format for tick val *x*. """ if x == 0.0: # Symlog return '0' x = abs(x) b = self._base # only label the decades fx = math.log(x) / math.log(b) is_x_decade = is_close_to_int(fx) exponent = np.round(fx) if is_x_decade else np.floor(fx) coeff = np.round(x / b ** exponent) if self.labelOnlyBase and not is_x_decade: return '' if self._sublabels is not None and coeff not in self._sublabels: return '' vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) s = self._num_to_string(x, vmin, vmax) return self.fix_minus(s)
Example #27
Source File: ticker.py From matplotlib-4-abaqus with MIT License | 6 votes |
def scale_range(vmin, vmax, n=1, threshold=100): dv = abs(vmax - vmin) if dv == 0: # maxabsv == 0 is a special case of this. return 1.0, 0.0 # Note: this should never occur because # vmin, vmax should have been checked by nonsingular(), # and spread apart if necessary. meanv = 0.5 * (vmax + vmin) if abs(meanv) / dv < threshold: offset = 0 elif meanv > 0: ex = divmod(math.log10(meanv), 1)[0] offset = 10 ** ex else: ex = divmod(math.log10(-meanv), 1)[0] offset = -10 ** ex ex = divmod(math.log10(dv / n), 1)[0] scale = 10 ** ex return scale, offset
Example #28
Source File: ticker.py From Computable with MIT License | 5 votes |
def zoom(self, direction): "Zoom in/out on axis; if direction is >0 zoom in, else zoom out" vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) interval = abs(vmax - vmin) step = 0.1 * interval * direction self.axis.set_view_interval(vmin + step, vmax - step, ignore=True)
Example #29
Source File: ticker.py From neural-network-animation with MIT License | 5 votes |
def view_limits(self, vmin, vmax): 'Try to choose the view limits intelligently' b = self._base if vmax < vmin: vmin, vmax = vmax, vmin if self.axis.axes.name == 'polar': vmax = math.ceil(math.log(vmax) / math.log(b)) vmin = b ** (vmax - self.numdecs) return vmin, vmax minpos = self.axis.get_minpos() if minpos <= 0 or not np.isfinite(minpos): raise ValueError( "Data has no positive values, and therefore can not be " "log-scaled.") if vmin <= minpos: vmin = minpos if not is_decade(vmin, self._base): vmin = decade_down(vmin, self._base) if not is_decade(vmax, self._base): vmax = decade_up(vmax, self._base) if vmin == vmax: vmin = decade_down(vmin, self._base) vmax = decade_up(vmax, self._base) result = mtransforms.nonsingular(vmin, vmax) return result
Example #30
Source File: ticker.py From neural-network-animation with MIT License | 5 votes |
def refresh(self): 'refresh internal information based on current lim' vmin, vmax = self.axis.get_view_interval() vmin, vmax = mtransforms.nonsingular(vmin, vmax, expander=0.05) d = abs(vmax - vmin) self._locator = self.get_locator(d)