-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Make axis.set_scale
private
#1917
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Next
Next commit
a wrapper function with depreciation warning.
- Loading branch information
commit 4003603ab20bfa18c09a673217a04df2bb908200
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
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 |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
import numpy as np | ||
import warnings | ||
|
||
from matplotlib import MatplotlibDeprecationWarning as mplDeprecation | ||
|
||
GRIDLINE_INTERPOLATION_STEPS = 180 | ||
|
||
|
||
|
@@ -652,7 +654,7 @@ def __init__(self, axes, pickradius=15): | |
self._minor_tick_kw = dict() | ||
|
||
self.cla() | ||
self.set_scale('linear') | ||
self._set_scale('linear') | ||
|
||
def set_label_coords(self, x, y, transform=None): | ||
""" | ||
|
@@ -683,6 +685,17 @@ def get_scale(self): | |
return self._scale.name | ||
|
||
def set_scale(self, value, **kwargs): | ||
""" | ||
Deprecatted 1.3. | ||
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. Typo: deprecated |
||
|
||
This sholud be a private function (moved to _set_scale) | ||
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. Typo: should |
||
""" | ||
warnings.warn("This function has been made private and moved" | ||
"to `_set_scale`. This wrapper function will be " | ||
"removed in 1.4", mplDeprecation) | ||
self._set_scale(value, **kwargs) | ||
|
||
def _set_scale(self, value, **kwargs): | ||
self._scale = mscale.scale_factory(value, self, **kwargs) | ||
self._scale.set_default_locators_and_formatters(self) | ||
|
||
|
@@ -982,19 +995,19 @@ def _update_ticks(self, renderer): | |
interval_expanded = interval | ||
else: | ||
interval_expanded = interval[1], interval[0] | ||
|
||
if hasattr(self, '_get_pixel_distance_along_axis'): | ||
# normally, one does not want to catch all exceptions that could possibly happen, but it | ||
# is not clear exactly what exceptions might arise from a user's projection (their rendition | ||
# of the Axis object). So, we catch all, with the idea that one would rather potentially | ||
# lose a tick from one side of the axis or another, rather than see a stack trace. | ||
try: | ||
ds1 = self._get_pixel_distance_along_axis(interval_expanded[0], -0.5) | ||
ds1 = self._get_pixel_distance_along_axis(interval_expanded[0], -0.5) | ||
except: | ||
warnings.warn("Unable to find pixel distance along axis for interval padding; assuming no interval padding needed.") | ||
ds1 = 0.0 | ||
try: | ||
ds2 = self._get_pixel_distance_along_axis(interval_expanded[1], +0.5) | ||
ds2 = self._get_pixel_distance_along_axis(interval_expanded[1], +0.5) | ||
except: | ||
warnings.warn("Unable to find pixel distance along axis for interval padding; assuming no interval padding needed.") | ||
ds2 = 0.0 | ||
|
@@ -1636,11 +1649,11 @@ def _get_pixel_distance_along_axis(self, where, perturb): | |
Implementing this routine for an axis is optional; if present, it will ensure that no | ||
ticks are lost due to round-off at the extreme ends of an axis. | ||
""" | ||
|
||
# Note that this routine does not work for a polar axis, because of the 1e-10 below. To | ||
# do things correctly, we need to use rmax instead of 1e-10 for a polar axis. But | ||
# since we do not have that kind of information at this point, we just don't try to | ||
# pad anything for the theta axis of a polar plot. | ||
# since we do not have that kind of information at this point, we just don't try to | ||
# pad anything for the theta axis of a polar plot. | ||
if self.axes.name == 'polar': | ||
return 0.0 | ||
|
||
|
@@ -1653,7 +1666,7 @@ def _get_pixel_distance_along_axis(self, where, perturb): | |
pix = trans.transform_point((where, 1e-10)) | ||
ptp = transinv.transform_point((pix[0] + perturb, pix[1])) # perturb the pixel. | ||
dx = abs(ptp[0] - where) | ||
|
||
return dx | ||
|
||
def get_label_position(self): | ||
|
@@ -1941,7 +1954,7 @@ def _get_pixel_distance_along_axis(self, where, perturb): | |
ticks are lost due to round-off at the extreme ends of an axis. | ||
""" | ||
|
||
# | ||
# | ||
# first figure out the pixel location of the "where" point. We use 1e-10 for the | ||
# x point, so that we remain compatible with log axes. | ||
# | ||
|
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 it is best to import this from where it really is: matplotlib.cbook