Place logarithmically spaced ticks. Places ticks at the values ``subs[j] * base**i``.
| 2397 | |
| 2398 | |
| 2399 | class LogLocator(Locator): |
| 2400 | """ |
| 2401 | Place logarithmically spaced ticks. |
| 2402 | |
| 2403 | Places ticks at the values ``subs[j] * base**i``. |
| 2404 | """ |
| 2405 | |
| 2406 | def __init__(self, base=10.0, subs=(1.0,), *, numticks=None): |
| 2407 | """ |
| 2408 | Parameters |
| 2409 | ---------- |
| 2410 | base : float, default: 10.0 |
| 2411 | The base of the log used, so major ticks are placed at ``base**n``, where |
| 2412 | ``n`` is an integer. |
| 2413 | subs : None or {'auto', 'all'} or sequence of float, default: (1.0,) |
| 2414 | Gives the multiples of integer powers of the base at which to place ticks. |
| 2415 | The default of ``(1.0, )`` places ticks only at integer powers of the base. |
| 2416 | Permitted string values are ``'auto'`` and ``'all'``. Both of these use an |
| 2417 | algorithm based on the axis view limits to determine whether and how to put |
| 2418 | ticks between integer powers of the base: |
| 2419 | - ``'auto'``: Ticks are placed only between integer powers. |
| 2420 | - ``'all'``: Ticks are placed between *and* at integer powers. |
| 2421 | - ``None``: Equivalent to ``'auto'``. |
| 2422 | numticks : None or int, default: None |
| 2423 | The maximum number of ticks to allow on a given axis. The default of |
| 2424 | ``None`` will try to choose intelligently as long as this Locator has |
| 2425 | already been assigned to an axis using `~.axis.Axis.get_tick_space`, but |
| 2426 | otherwise falls back to 9. |
| 2427 | """ |
| 2428 | if numticks is None: |
| 2429 | if mpl.rcParams['_internal.classic_mode']: |
| 2430 | numticks = 15 |
| 2431 | else: |
| 2432 | numticks = 'auto' |
| 2433 | self._base = float(base) |
| 2434 | self._set_subs(subs) |
| 2435 | self.numticks = numticks |
| 2436 | |
| 2437 | def set_params(self, base=None, subs=None, *, numticks=None): |
| 2438 | """Set parameters within this locator.""" |
| 2439 | if base is not None: |
| 2440 | self._base = float(base) |
| 2441 | if subs is not None: |
| 2442 | self._set_subs(subs) |
| 2443 | if numticks is not None: |
| 2444 | self.numticks = numticks |
| 2445 | |
| 2446 | def _set_subs(self, subs): |
| 2447 | """ |
| 2448 | Set the minor ticks for the log scaling every ``base**i*subs[j]``. |
| 2449 | """ |
| 2450 | if subs is None: # consistency with previous bad API |
| 2451 | self._subs = 'auto' |
| 2452 | elif isinstance(subs, str): |
| 2453 | _api.check_in_list(('all', 'auto'), subs=subs) |
| 2454 | self._subs = subs |
| 2455 | else: |
| 2456 | try: |
no outgoing calls
no test coverage detected
searching dependent graphs…