-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Updated argument to mpl.ticker.LogFormatter.label_minor
#6264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -829,13 +829,13 @@ class LogFormatter(Formatter): | |
""" | ||
Format values for log axis. | ||
""" | ||
def __init__(self, base=10.0, labelOnlyBase=True): | ||
def __init__(self, base=10.0, label_only_base=True): | ||
""" | ||
`base` is used to locate the decade tick, which will be the only | ||
one to be labeled if `labelOnlyBase` is ``True``. | ||
one to be labeled if `label_only_base` is ``True``. | ||
""" | ||
self._base = base + 0.0 | ||
self.labelOnlyBase = labelOnlyBase | ||
self.label_only_base = label_only_base | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also a public API break which should be patched over with a property, but should also wait for changing the parameter name in the |
||
self.sublabel = [1, ] | ||
|
||
def base(self, base): | ||
|
@@ -848,13 +848,13 @@ def base(self, base): | |
""" | ||
self._base = base | ||
|
||
def label_minor(self, labelOnlyBase): | ||
def label_minor(self, label_only_base): | ||
""" | ||
Switch minor tick labeling on or off. | ||
Switch intermediate tick labeling on or off. | ||
|
||
``labelOnlyBase=True`` to turn off minor ticks. | ||
``label_only_base=True`` to turn off minor (non-decade) ticks. | ||
""" | ||
self.labelOnlyBase = labelOnlyBase | ||
self.label_only_base = label_only_base | ||
|
||
def set_locs(self, locs): | ||
b = self._base | ||
|
@@ -903,11 +903,11 @@ def __call__(self, x, pos=None): | |
x = abs(x) | ||
# only label the decades | ||
fx = math.log(x) / math.log(b) | ||
isDecade = is_close_to_int(fx) | ||
exponent = np.round(fx) if isDecade else np.floor(fx) | ||
is_decade = is_close_to_int(fx) | ||
exponent = np.round(fx) if is_decade else np.floor(fx) | ||
coeff = np.round(x / b ** exponent) | ||
if coeff in self.sublabel: | ||
if not isDecade and self.labelOnlyBase: | ||
if not is_decade and self.label_only_base: | ||
return '' | ||
elif x > 10000: | ||
s = '%1.0e' % x | ||
|
@@ -923,10 +923,10 @@ def __call__(self, x, pos=None): | |
return self.fix_minus(s) | ||
|
||
def format_data(self, value): | ||
b = self.labelOnlyBase | ||
self.labelOnlyBase = False | ||
b = self.label_only_base | ||
self.label_only_base = False | ||
value = cbook.strip_math(self.__call__(value)) | ||
self.labelOnlyBase = b | ||
self.label_only_base = b | ||
return value | ||
|
||
def format_data_short(self, value): | ||
|
@@ -987,8 +987,8 @@ def __call__(self, x, pos=None): | |
sign = np.sign(x) | ||
# only label the decades | ||
fx = math.log(abs(x)) / math.log(b) | ||
isDecade = is_close_to_int(fx) | ||
if not isDecade and self.labelOnlyBase: | ||
is_decade = is_close_to_int(fx) | ||
if not is_decade and self.label_only_base: | ||
s = '' | ||
elif abs(fx) > 10000: | ||
s = '%1.0g' % fx | ||
|
@@ -1046,7 +1046,7 @@ def __call__(self, x, pos=None): | |
base = '%s' % b | ||
|
||
if coeff in self.sublabel: | ||
if not is_decade and self.labelOnlyBase: | ||
if not is_decade and self.label_only_basee: | ||
return '' | ||
elif not is_decade: | ||
return self._non_decade_format(sign_string, base, fx, usetex) | ||
|
@@ -1068,9 +1068,9 @@ class LogFormatterSciNotation(LogFormatterMathtext): | |
Format values following scientific notation in a logarithmic axis | ||
""" | ||
|
||
def __init__(self, base=10.0, labelOnlyBase=False): | ||
def __init__(self, base=10.0, label_only_base=False): | ||
super(LogFormatterSciNotation, self).__init__(base=base, | ||
labelOnlyBase=labelOnlyBase) | ||
label_only_base=label_only_base) | ||
|
||
def _non_decade_format(self, sign_string, base, fx, usetex): | ||
'Return string for non-decade locations' | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this fix has to hold off until we have python3 only and can do
and then deprecate it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can do this for both with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The easiest way to do this is
…, label_only_base=True, labelOnlyBase=None
and check whether labelOnlyBase was provided to deprecate it.