r""" Place ticks at a set of fixed values. If *nbins* is None ticks are placed at all values. Otherwise, the *locs* array of possible positions will be subsampled to keep the number of ticks :math:`\leq nbins + 1`. The subsampling will be done to include the smallest absolute va
| 1838 | |
| 1839 | |
| 1840 | class FixedLocator(Locator): |
| 1841 | r""" |
| 1842 | Place ticks at a set of fixed values. |
| 1843 | |
| 1844 | If *nbins* is None ticks are placed at all values. Otherwise, the *locs* array of |
| 1845 | possible positions will be subsampled to keep the number of ticks |
| 1846 | :math:`\leq nbins + 1`. The subsampling will be done to include the smallest |
| 1847 | absolute value; for example, if zero is included in the array of possibilities, then |
| 1848 | it will be included in the chosen ticks. |
| 1849 | """ |
| 1850 | |
| 1851 | def __init__(self, locs, nbins=None): |
| 1852 | self.locs = np.asarray(locs) |
| 1853 | _api.check_shape((None,), locs=self.locs) |
| 1854 | self.nbins = max(nbins, 2) if nbins is not None else None |
| 1855 | |
| 1856 | def set_params(self, nbins=None): |
| 1857 | """Set parameters within this locator.""" |
| 1858 | if nbins is not None: |
| 1859 | self.nbins = nbins |
| 1860 | |
| 1861 | def __call__(self): |
| 1862 | return self.tick_values(None, None) |
| 1863 | |
| 1864 | def tick_values(self, vmin, vmax): |
| 1865 | """ |
| 1866 | Return the locations of the ticks. |
| 1867 | |
| 1868 | .. note:: |
| 1869 | |
| 1870 | Because the values are fixed, *vmin* and *vmax* are not used. |
| 1871 | """ |
| 1872 | if self.nbins is None: |
| 1873 | return self.locs |
| 1874 | step = max(int(np.ceil(len(self.locs) / self.nbins)), 1) |
| 1875 | ticks = self.locs[::step] |
| 1876 | for i in range(1, step): |
| 1877 | ticks1 = self.locs[i::step] |
| 1878 | if np.abs(ticks1).min() < np.abs(ticks).min(): |
| 1879 | ticks = ticks1 |
| 1880 | return self.raise_if_exceeds(ticks) |
| 1881 | |
| 1882 | |
| 1883 | class NullLocator(Locator): |
no outgoing calls
searching dependent graphs…