From 4003603ab20bfa18c09a673217a04df2bb908200 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 17 Apr 2013 23:13:24 -0500 Subject: [PATCH 1/2] Addresses fixes #1871 by making `axis.set_scale` private and adding a wrapper function with depreciation warning. --- lib/matplotlib/axes.py | 14 +++++++------- lib/matplotlib/axis.py | 31 ++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/lib/matplotlib/axes.py b/lib/matplotlib/axes.py index 2c06ff86f8c0..a1476c6f2bd0 100644 --- a/lib/matplotlib/axes.py +++ b/lib/matplotlib/axes.py @@ -866,7 +866,7 @@ 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) @@ -874,7 +874,7 @@ def cla(self): 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 @@ -889,7 +889,7 @@ 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) @@ -897,7 +897,7 @@ def cla(self): 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 @@ -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() @@ -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() @@ -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): diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 32cf293580c6..66d568fe8ecf 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -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. + + This sholud be a private function (moved to _set_scale) + """ + 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. # From d2eb877b6d20fdeb47774e7c2e3285dd91833430 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 24 Apr 2013 15:13:34 -0500 Subject: [PATCH 2/2] Spelling and import tweaks it axis.py. --- lib/matplotlib/axis.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/axis.py b/lib/matplotlib/axis.py index 66d568fe8ecf..98c1835deba4 100644 --- a/lib/matplotlib/axis.py +++ b/lib/matplotlib/axis.py @@ -18,7 +18,7 @@ import numpy as np import warnings -from matplotlib import MatplotlibDeprecationWarning as mplDeprecation +from cbook import mplDeprecation GRIDLINE_INTERPOLATION_STEPS = 180 @@ -686,9 +686,9 @@ def get_scale(self): def set_scale(self, value, **kwargs): """ - Deprecatted 1.3. + Deprecated 1.3. - This sholud be a private function (moved to _set_scale) + This should be a private function (moved to _set_scale) """ warnings.warn("This function has been made private and moved" "to `_set_scale`. This wrapper function will be " pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy