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

Class EngFormatter

lib/matplotlib/ticker.py:1404–1604  ·  view source on GitHub ↗

Format axis values using engineering prefixes to represent powers of 1000, plus a specified unit, e.g., 10 MHz instead of 1e7.

Source from the content-addressed store, hash-verified

1402
1403
1404class EngFormatter(ScalarFormatter):
1405 """
1406 Format axis values using engineering prefixes to represent powers
1407 of 1000, plus a specified unit, e.g., 10 MHz instead of 1e7.
1408 """
1409
1410 # The SI engineering prefixes
1411 ENG_PREFIXES = {
1412 -30: "q",
1413 -27: "r",
1414 -24: "y",
1415 -21: "z",
1416 -18: "a",
1417 -15: "f",
1418 -12: "p",
1419 -9: "n",
1420 -6: "\N{MICRO SIGN}",
1421 -3: "m",
1422 0: "",
1423 3: "k",
1424 6: "M",
1425 9: "G",
1426 12: "T",
1427 15: "P",
1428 18: "E",
1429 21: "Z",
1430 24: "Y",
1431 27: "R",
1432 30: "Q"
1433 }
1434
1435 def __init__(self, unit="", places=None, sep=" ", *, usetex=None,
1436 useMathText=None, useOffset=False):
1437 r"""
1438 Parameters
1439 ----------
1440 unit : str, default: ""
1441 Unit symbol to use, suitable for use with single-letter
1442 representations of powers of 1000. For example, 'Hz' or 'm'.
1443
1444 places : int, default: None
1445 Precision with which to display the number, specified in
1446 digits after the decimal point (there will be between one
1447 and three digits before the decimal point). If it is None,
1448 the formatting falls back to the floating point format '%g',
1449 which displays up to 6 *significant* digits, i.e. the equivalent
1450 value for *places* varies between 0 and 5 (inclusive).
1451
1452 sep : str, default: " "
1453 Separator used between the value and the prefix/unit. For
1454 example, one get '3.14 mV' if ``sep`` is " " (default) and
1455 '3.14mV' if ``sep`` is "". Besides the default behavior, some
1456 other useful options may be:
1457
1458 * ``sep=""`` to append directly the prefix/unit to the value;
1459 * ``sep="\N{THIN SPACE}"`` (``U+2009``);
1460 * ``sep="\N{NARROW NO-BREAK SPACE}"`` (``U+202F``);
1461 * ``sep="\N{NO-BREAK SPACE}"`` (``U+00A0``).

Callers 2

run_memleak_testFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…