Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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 2 commits into from
May 13, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

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
Addresses fixes #1871 by making axis.set_scale private and adding
a wrapper function with depreciation warning.
  • Loading branch information
tacaswell committed Apr 18, 2013
commit 4003603ab20bfa18c09a673217a04df2bb908200
14 changes: 7 additions & 7 deletions 14 lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,15 +866,15 @@ def cla(self):
minl = self._sharex.xaxis.get_minor_locator()

# This overwrites the current formatter/locator
self.xaxis.set_scale(self._sharex.xaxis.get_scale())
self.xaxis._set_scale(self._sharex.xaxis.get_scale())

# Reset the formatter/locator
self.xaxis.set_major_formatter(majf)
self.xaxis.set_minor_formatter(minf)
self.xaxis.set_major_locator(majl)
self.xaxis.set_minor_locator(minl)
else:
self.xaxis.set_scale('linear')
self.xaxis._set_scale('linear')

if self._sharey is not None:
self.yaxis.major = self._sharey.yaxis.major
Expand All @@ -889,15 +889,15 @@ def cla(self):
minl = self._sharey.yaxis.get_minor_locator()

# This overwrites the current formatter/locator
self.yaxis.set_scale(self._sharey.yaxis.get_scale())
self.yaxis._set_scale(self._sharey.yaxis.get_scale())

# Reset the formatter/locator
self.yaxis.set_major_formatter(majf)
self.yaxis.set_minor_formatter(minf)
self.yaxis.set_major_locator(majl)
self.yaxis.set_minor_locator(minl)
else:
self.yaxis.set_scale('linear')
self.yaxis._set_scale('linear')

self._autoscaleXon = True
self._autoscaleYon = True
Expand Down Expand Up @@ -2575,7 +2575,7 @@ def set_xscale(self, value, **kwargs):
Different kwargs are accepted, depending on the scale:
%(scale_docs)s
"""
self.xaxis.set_scale(value, **kwargs)
self.xaxis._set_scale(value, **kwargs)
self.autoscale_view(scaley=False)
self._update_transScale()

Expand Down Expand Up @@ -2800,7 +2800,7 @@ def set_yscale(self, value, **kwargs):
Different kwargs are accepted, depending on the scale:
%(scale_docs)s
"""
self.yaxis.set_scale(value, **kwargs)
self.yaxis._set_scale(value, **kwargs)
self.autoscale_view(scalex=False)
self._update_transScale()

Expand Down Expand Up @@ -9076,7 +9076,7 @@ def matshow(self, Z, **kwargs):
return im

def get_default_bbox_extra_artists(self):
return [artist for artist in self.get_children()
return [artist for artist in self.get_children()
if artist.get_visible()]

def get_tightbbox(self, renderer, call_axes_locator=True):
Expand Down
31 changes: 22 additions & 9 deletions 31 lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import numpy as np
import warnings

from matplotlib import MatplotlibDeprecationWarning as mplDeprecation
Copy link
Member

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


GRIDLINE_INTERPOLATION_STEPS = 180


Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -683,6 +685,17 @@ def get_scale(self):
return self._scale.name

def set_scale(self, value, **kwargs):
"""
Deprecatted 1.3.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: deprecated


This sholud be a private function (moved to _set_scale)
Copy link
Member

Choose a reason for hiding this comment

The 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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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):
Expand Down Expand Up @@ -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.
#
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.