MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / tick_values

Method tick_values

lib/matplotlib/ticker.py:2688–2772  ·  view source on GitHub ↗
(self, vmin, vmax)

Source from the content-addressed store, hash-verified

2686 return self.tick_values(vmin, vmax)
2687
2688 def tick_values(self, vmin, vmax):
2689 linthresh = self._linthresh
2690
2691 if vmax < vmin:
2692 vmin, vmax = vmax, vmin
2693
2694 # The domain is divided into three sections, only some of
2695 # which may actually be present.
2696 #
2697 # <======== -t ==0== t ========>
2698 # aaaaaaaaa bbbbb ccccccccc
2699 #
2700 # a) and c) will have ticks at integral log positions. The
2701 # number of ticks needs to be reduced if there are more
2702 # than self.numticks of them.
2703 #
2704 # b) has a tick at 0 and only 0 (we assume t is a small
2705 # number, and the linear segment is just an implementation
2706 # detail and not interesting.)
2707 #
2708 # We could also add ticks at t, but that seems to usually be
2709 # uninteresting.
2710 #
2711 # "simple" mode is when the range falls entirely within [-t, t]
2712 # -- it should just display (vmin, 0, vmax)
2713 if -linthresh <= vmin < vmax <= linthresh:
2714 # only the linear range is present
2715 return sorted({vmin, 0, vmax})
2716
2717 # Lower log range is present
2718 has_a = (vmin < -linthresh)
2719 # Upper log range is present
2720 has_c = (vmax > linthresh)
2721
2722 # Check if linear range is present
2723 has_b = (has_a and vmax > -linthresh) or (has_c and vmin < linthresh)
2724
2725 base = self._base
2726
2727 def get_log_range(lo, hi):
2728 lo = np.floor(np.log(lo) / np.log(base))
2729 hi = np.ceil(np.log(hi) / np.log(base))
2730 return lo, hi
2731
2732 # Calculate all the ranges, so we can determine striding
2733 a_lo, a_hi = (0, 0)
2734 if has_a:
2735 a_upper_lim = min(-linthresh, vmax)
2736 a_lo, a_hi = get_log_range(abs(a_upper_lim), abs(vmin) + 1)
2737
2738 c_lo, c_hi = (0, 0)
2739 if has_c:
2740 c_lower_lim = max(linthresh, vmin)
2741 c_lo, c_hi = get_log_range(c_lower_lim, vmax + 1)
2742
2743 # Calculate the total number of integer exponents in a and c ranges
2744 total_ticks = (a_hi - a_lo) + (c_hi - c_lo)
2745 if has_b:

Callers 2

__call__Method · 0.95
test_valuesMethod · 0.95

Calls 1

raise_if_exceedsMethod · 0.80

Tested by 1

test_valuesMethod · 0.76