Format tick values as a number. Parameters ---------- useOffset : bool or float, default: :rc:`axes.formatter.useoffset` Whether to use offset notation. See `.set_useOffset`. useMathText : bool, default: :rc:`axes.formatter.use_mathtext` Whether to use fancy mat
| 455 | |
| 456 | |
| 457 | class ScalarFormatter(Formatter): |
| 458 | """ |
| 459 | Format tick values as a number. |
| 460 | |
| 461 | Parameters |
| 462 | ---------- |
| 463 | useOffset : bool or float, default: :rc:`axes.formatter.useoffset` |
| 464 | Whether to use offset notation. See `.set_useOffset`. |
| 465 | useMathText : bool, default: :rc:`axes.formatter.use_mathtext` |
| 466 | Whether to use fancy math formatting. See `.set_useMathText`. |
| 467 | useLocale : bool, default: :rc:`axes.formatter.use_locale`. |
| 468 | Whether to use locale settings for decimal sign and positive sign. |
| 469 | See `.set_useLocale`. |
| 470 | usetex : bool, default: :rc:`text.usetex` |
| 471 | To enable/disable the use of TeX's math mode for rendering the |
| 472 | numbers in the formatter. |
| 473 | |
| 474 | .. versionadded:: 3.10 |
| 475 | |
| 476 | Notes |
| 477 | ----- |
| 478 | In addition to the parameters above, the formatting of scientific vs. |
| 479 | floating point representation can be configured via `.set_scientific` |
| 480 | and `.set_powerlimits`). |
| 481 | |
| 482 | **Offset notation and scientific notation** |
| 483 | |
| 484 | Offset notation and scientific notation look quite similar at first sight. |
| 485 | Both split some information from the formatted tick values and display it |
| 486 | at the end of the axis. |
| 487 | |
| 488 | - The scientific notation splits up the order of magnitude, i.e. a |
| 489 | multiplicative scaling factor, e.g. ``1e6``. |
| 490 | |
| 491 | - The offset notation separates an additive constant, e.g. ``+1e6``. The |
| 492 | offset notation label is always prefixed with a ``+`` or ``-`` sign |
| 493 | and is thus distinguishable from the order of magnitude label. |
| 494 | |
| 495 | The following plot with x limits ``1_000_000`` to ``1_000_010`` illustrates |
| 496 | the different formatting. Note the labels at the right edge of the x axis. |
| 497 | |
| 498 | .. plot:: |
| 499 | |
| 500 | lim = (1_000_000, 1_000_010) |
| 501 | |
| 502 | fig, (ax1, ax2, ax3) = plt.subplots(3, 1, gridspec_kw={'hspace': 2}) |
| 503 | ax1.set(title='offset notation', xlim=lim) |
| 504 | ax2.set(title='scientific notation', xlim=lim) |
| 505 | ax2.xaxis.get_major_formatter().set_useOffset(False) |
| 506 | ax3.set(title='floating-point notation', xlim=lim) |
| 507 | ax3.xaxis.get_major_formatter().set_useOffset(False) |
| 508 | ax3.xaxis.get_major_formatter().set_scientific(False) |
| 509 | |
| 510 | """ |
| 511 | |
| 512 | orderOfMagnitude = _api.deprecate_privatize_attribute("3.11") |
| 513 | format = _api.deprecate_privatize_attribute("3.11") |
| 514 |
no outgoing calls
searching dependent graphs…