@@ -484,11 +484,21 @@ class ScalarFormatter(Formatter):
484
484
"""
485
485
Format tick values as a number.
486
486
487
- If ``useOffset == True`` and the data range is much smaller than the data
488
- average, then an offset will be determined such that the tick labels
489
- are meaningful. Scientific notation is used for ``data < 10^n`` or
490
- ``data >= 10^m``, where ``n`` and ``m`` are the power limits set using
491
- ``set_powerlimits((n, m))``, defaulting to :rc:`axes.formatter.limits`.
487
+ Parameters
488
+ ----------
489
+ useOffset : bool or float, default: :rc:`axes.formatter.useoffset`
490
+ Whether to use offset notation. See `.set_useOffset`.
491
+ useMathText : bool, default: :rc:`axes.formatter.use_mathtext`
492
+ Whether to use fancy math formatting. See `.set_useMathText`.
493
+ useLocale : bool, default: :rc:`axes.formatter.use_locale`.
494
+ Whether to use locale settings for decimal sign and positive sign.
495
+ See `.set_useLocale`.
496
+
497
+ Notes
498
+ -----
499
+ In addition to the parameters above, the formatting of scientific vs.
500
+ floating point representation can be configured via `.set_scientific`
501
+ and `.set_powerlimits`).
492
502
"""
493
503
494
504
def __init__ (self , useOffset = None , useMathText = None , useLocale = None ):
@@ -514,9 +524,45 @@ def __init__(self, useOffset=None, useMathText=None, useLocale=None):
514
524
self ._useLocale = useLocale
515
525
516
526
def get_useOffset (self ):
527
+ """
528
+ Return whether automatic mode for offset notation is active.
529
+
530
+ This returns True if ``set_useOffset(True)``; it returns False if an
531
+ explicit offset was set, e.g. ``set_useOffset(1000)``.
532
+
533
+ See Also
534
+ --------
535
+ ScalarFormatter.set_useOffset
536
+ """
517
537
return self ._useOffset
518
538
519
539
def set_useOffset (self , val ):
540
+ """
541
+ Set whether to use offset notation.
542
+
543
+ When formatting a set numbers whose value is large compared to their
544
+ range, the formatter can separate an additive constant. This can
545
+ shorten the formatted numbers so that they are less likely to overlap
546
+ when drawn on an axis.
547
+
548
+ Parameters
549
+ ----------
550
+ val : bool or float
551
+ - If False, do not use offset notation.
552
+ - If True (=automatic mode), use offset notation if it can make
553
+ the residual numbers significantly shorter. The exact behavior
554
+ is controlled by :rc:`axes.formatter.offset_threshold`.
555
+ - If a number, force an offset of the given value.
556
+
557
+ Examples
558
+ --------
559
+ With active offset notation, the values
560
+
561
+ ``100_000, 100_002, 100_004, 100_006, 100_008``
562
+
563
+ will be formatted as ``0, 2, 4, 6, 8`` plus an offset ``+1e5``, which
564
+ is written to the edge of the axis.
565
+ """
520
566
if val in [True , False ]:
521
567
self .offset = 0
522
568
self ._useOffset = val
@@ -527,9 +573,24 @@ def set_useOffset(self, val):
527
573
useOffset = property (fget = get_useOffset , fset = set_useOffset )
528
574
529
575
def get_useLocale (self ):
576
+ """
577
+ Return whether locale settings are used for formatting.
578
+
579
+ See Also
580
+ --------
581
+ ScalarFormatter.set_useLocale
582
+ """
530
583
return self ._useLocale
531
584
532
585
def set_useLocale (self , val ):
586
+ """
587
+ Set whether to use locale settings for decimal sign and positive sign.
588
+
589
+ Parameters
590
+ ----------
591
+ val : bool or None
592
+ *None* resets to :rc:`axes.formatter.use_locale`.
593
+ """
533
594
if val is None :
534
595
self ._useLocale = mpl .rcParams ['axes.formatter.use_locale' ]
535
596
else :
@@ -538,9 +599,26 @@ def set_useLocale(self, val):
538
599
useLocale = property (fget = get_useLocale , fset = set_useLocale )
539
600
540
601
def get_useMathText (self ):
602
+ """
603
+ Return whether to use fancy math formatting.
604
+
605
+ See Also
606
+ --------
607
+ ScalarFormatter.set_useMathText
608
+ """
541
609
return self ._useMathText
542
610
543
611
def set_useMathText (self , val ):
612
+ r"""
613
+ Set whether to use fancy math formatting.
614
+
615
+ If active, scientific notation is formatted as :math:`1.2 \times 10^3`.
616
+
617
+ Parameters
618
+ ----------
619
+ val : bool or None
620
+ *None* resets to :rc:`axes.formatter.use_mathtext`.
621
+ """
544
622
if val is None :
545
623
self ._useMathText = mpl .rcParams ['axes.formatter.use_mathtext' ]
546
624
else :
0 commit comments