Skip to content

Commit 851fa4a

Browse files
committed
logitscale: add option to LogitScale, passed to LogitFormatter
1 parent 98e670d commit 851fa4a

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

lib/matplotlib/scale.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,15 @@ class LogitScale(ScaleBase):
654654
"""
655655
name = 'logit'
656656

657-
def __init__(self, axis, nonpos='mask'):
658-
"""
657+
def __init__(
658+
self,
659+
axis,
660+
nonpos='mask',
661+
*,
662+
one_half=r"\frac{1}{2}",
663+
use_overline=False,
664+
):
665+
r"""
659666
Parameters
660667
----------
661668
axis : `matplotlib.axis.Axis`
@@ -664,8 +671,15 @@ def __init__(self, axis, nonpos='mask'):
664671
Determines the behavior for values beyond the open interval ]0, 1[.
665672
They can either be masked as invalid, or clipped to a number very
666673
close to 0 or 1.
674+
use_overline: bool (default: False)
675+
indicate the usage of survival notation (\overline{x}) in place of
676+
standard notation (1-x) for probability close to one.
677+
one_half : str (default: r"\frac{1}{2}")
678+
the string used for ticks formatter to represent 1/2.
667679
"""
668680
self._transform = LogitTransform(nonpos)
681+
self._use_overline = use_overline
682+
self._one_half = one_half
669683

670684
def get_transform(self):
671685
"""Return the `.LogitTransform` associated with this scale."""
@@ -675,9 +689,20 @@ def set_default_locators_and_formatters(self, axis):
675689
# docstring inherited
676690
# ..., 0.01, 0.1, 0.5, 0.9, 0.99, ...
677691
axis.set_major_locator(LogitLocator())
678-
axis.set_major_formatter(LogitFormatter())
692+
axis.set_major_formatter(
693+
LogitFormatter(
694+
one_half=self._one_half,
695+
use_overline=self._use_overline
696+
)
697+
)
679698
axis.set_minor_locator(LogitLocator(minor=True))
680-
axis.set_minor_formatter(LogitFormatter())
699+
axis.set_minor_formatter(
700+
LogitFormatter(
701+
minor=True,
702+
one_half=self._one_half,
703+
use_overline=self._use_overline
704+
)
705+
)
681706

682707
def limit_range_for_scale(self, vmin, vmax, minpos):
683708
"""

0 commit comments

Comments
 (0)