| 2912 | self.set_params(minor=value) |
| 2913 | |
| 2914 | def tick_values(self, vmin, vmax): |
| 2915 | # dummy axis has no axes attribute |
| 2916 | if hasattr(self.axis, "axes") and self.axis.axes.name == "polar": |
| 2917 | raise NotImplementedError("Polar axis cannot be logit scaled yet") |
| 2918 | |
| 2919 | if self._nbins == "auto": |
| 2920 | if self.axis is not None: |
| 2921 | nbins = self.axis.get_tick_space() |
| 2922 | if nbins < 2: |
| 2923 | nbins = 2 |
| 2924 | else: |
| 2925 | nbins = 9 |
| 2926 | else: |
| 2927 | nbins = self._nbins |
| 2928 | |
| 2929 | # We define ideal ticks with their index: |
| 2930 | # linscale: ... 1e-3 1e-2 1e-1 1/2 1-1e-1 1-1e-2 1-1e-3 ... |
| 2931 | # b-scale : ... -3 -2 -1 0 1 2 3 ... |
| 2932 | def ideal_ticks(x): |
| 2933 | return 10 ** x if x < 0 else 1 - (10 ** (-x)) if x > 0 else 0.5 |
| 2934 | |
| 2935 | vmin, vmax = self.nonsingular(vmin, vmax) |
| 2936 | binf = int( |
| 2937 | np.floor(np.log10(vmin)) |
| 2938 | if vmin < 0.5 |
| 2939 | else 0 |
| 2940 | if vmin < 0.9 |
| 2941 | else -np.ceil(np.log10(1 - vmin)) |
| 2942 | ) |
| 2943 | bsup = int( |
| 2944 | np.ceil(np.log10(vmax)) |
| 2945 | if vmax <= 0.5 |
| 2946 | else 1 |
| 2947 | if vmax <= 0.9 |
| 2948 | else -np.floor(np.log10(1 - vmax)) |
| 2949 | ) |
| 2950 | numideal = bsup - binf - 1 |
| 2951 | if numideal >= 2: |
| 2952 | # have 2 or more wanted ideal ticks, so use them as major ticks |
| 2953 | if numideal > nbins: |
| 2954 | # to many ideal ticks, subsampling ideals for major ticks, and |
| 2955 | # take others for minor ticks |
| 2956 | subsampling_factor = math.ceil(numideal / nbins) |
| 2957 | if self._minor: |
| 2958 | ticklocs = [ |
| 2959 | ideal_ticks(b) |
| 2960 | for b in range(binf, bsup + 1) |
| 2961 | if (b % subsampling_factor) != 0 |
| 2962 | ] |
| 2963 | else: |
| 2964 | ticklocs = [ |
| 2965 | ideal_ticks(b) |
| 2966 | for b in range(binf, bsup + 1) |
| 2967 | if (b % subsampling_factor) == 0 |
| 2968 | ] |
| 2969 | return self.raise_if_exceeds(np.array(ticklocs)) |
| 2970 | if self._minor: |
| 2971 | ticklocs = [] |