Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c24a7c

Browse files
committed
removed deprecated methods from the axes module. Added some DeprecatedWarnings in places where there should have been some
1 parent f2ff060 commit 2c24a7c

File tree

1 file changed

+34
-97
lines changed

1 file changed

+34
-97
lines changed

lib/matplotlib/axes.py

Lines changed: 34 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -139,25 +139,6 @@ def _process_plot_format(fmt):
139139
return linestyle, marker, color
140140

141141

142-
def set_default_color_cycle(clist):
143-
"""
144-
Change the default cycle of colors that will be used by the plot
145-
command. This must be called before creating the
146-
:class:`Axes` to which it will apply; it will
147-
apply to all future axes.
148-
149-
*clist* is a sequence of mpl color specifiers.
150-
151-
See also: :meth:`~matplotlib.axes.Axes.set_color_cycle`.
152-
153-
.. Note:: Deprecated 2010/01/03.
154-
Set rcParams['axes.color_cycle'] directly.
155-
156-
"""
157-
rcParams['axes.color_cycle'] = clist
158-
warnings.warn("Set rcParams['axes.color_cycle'] directly", mplDeprecation)
159-
160-
161142
class _process_plot_var_args(object):
162143
"""
163144
Process variable length arguments to the plot command, so that
@@ -282,12 +263,11 @@ def _makefill(self, x, y, kw, kwargs):
282263
facecolor = kw['color']
283264
except KeyError:
284265
facecolor = self.color_cycle.next()
285-
seg = mpatches.Polygon(np.hstack(
286-
(x[:, np.newaxis], y[:, np.newaxis])),
287-
facecolor=facecolor,
288-
fill=True,
289-
closed=kw['closed']
290-
)
266+
seg = mpatches.Polygon(np.hstack((x[:, np.newaxis],
267+
y[:, np.newaxis])),
268+
facecolor=facecolor,
269+
fill=True,
270+
closed=kw['closed'])
291271
self.set_patchprops(seg, **kwargs)
292272
return seg
293273

@@ -586,9 +566,9 @@ def _set_lim_and_transforms(self):
586566
self.transData = self.transScale + (self.transLimits + self.transAxes)
587567

588568
self._xaxis_transform = mtransforms.blended_transform_factory(
589-
self.transData, self.transAxes)
569+
self.transData, self.transAxes)
590570
self._yaxis_transform = mtransforms.blended_transform_factory(
591-
self.transAxes, self.transData)
571+
self.transAxes, self.transData)
592572

593573
def get_xaxis_transform(self, which='grid'):
594574
"""
@@ -1067,11 +1047,16 @@ def set_aspect(self, aspect, adjustable=None, anchor=None):
10671047
etc.
10681048
===== =====================
10691049
1050+
.. deprecated:: 1.2
1051+
the option 'normal' for aspect is deprecated. Use 'auto' instead.
10701052
"""
1071-
if aspect in ('normal', 'auto'):
1053+
if aspect == 'normal':
1054+
raise DeprecationWarning("Use 'auto' instead of 'normal' for "
1055+
"aspect. Will be removed in 1.4.x")
10721056
self._aspect = 'auto'
1073-
elif aspect == 'equal':
1074-
self._aspect = 'equal'
1057+
1058+
elif aspect in ('equal', 'auto'):
1059+
self._aspect = aspect
10751060
else:
10761061
self._aspect = float(aspect) # raise ValueError if necessary
10771062

@@ -1370,14 +1355,6 @@ def axis(self, *v, **kwargs):
13701355

13711356
return v
13721357

1373-
def get_child_artists(self):
1374-
"""
1375-
Return a list of artists the axes contains.
1376-
1377-
.. deprecated:: 0.98
1378-
"""
1379-
raise mplDeprecation('Use get_children instead')
1380-
13811358
def get_frame(self):
13821359
"""Return the axes Rectangle frame"""
13831360
warnings.warn('use ax.patch instead', mplDeprecation)
@@ -3108,30 +3085,6 @@ def set_cursor_props(self, *args):
31083085
c = mcolors.colorConverter.to_rgba(c)
31093086
self._cursorProps = lw, c
31103087

3111-
def connect(self, s, func):
3112-
"""
3113-
Register observers to be notified when certain events occur. Register
3114-
with callback functions with the following signatures. The function
3115-
has the following signature::
3116-
3117-
func(ax) # where ax is the instance making the callback.
3118-
3119-
The following events can be connected to:
3120-
3121-
'xlim_changed','ylim_changed'
3122-
3123-
The connection id is is returned - you can use this with
3124-
disconnect to disconnect from the axes event
3125-
3126-
"""
3127-
raise mplDeprecation('use the callbacks CallbackRegistry instance '
3128-
'instead')
3129-
3130-
def disconnect(self, cid):
3131-
"""disconnect from the Axes event."""
3132-
raise mplDeprecation('use the callbacks CallbackRegistry instance '
3133-
'instead')
3134-
31353088
def get_children(self):
31363089
"""return a list of child artists"""
31373090
children = []
@@ -3180,9 +3133,6 @@ def pick(self, *args):
31803133
each child artist will fire a pick event if mouseevent is over
31813134
the artist and the artist has picker set
31823135
"""
3183-
if len(args) > 1:
3184-
raise mplDeprecation('New pick API implemented -- '
3185-
'see API_CHANGES in the src distribution')
31863136
martist.Artist.pick(self, args[0])
31873137

31883138
### Labelling
@@ -3679,10 +3629,6 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
36793629
36803630
.. plot:: mpl_examples/pylab_examples/hline_demo.py
36813631
"""
3682-
if kwargs.get('fmt') is not None:
3683-
raise mplDeprecation('hlines now uses a '
3684-
'collections.LineCollection and not a '
3685-
'list of Line2D to draw; see API_CHANGES')
36863632

36873633
# We do the conversion first since not all unitized data is uniform
36883634
# process the unit information
@@ -3761,11 +3707,6 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
37613707
%(LineCollection)s
37623708
"""
37633709

3764-
if kwargs.get('fmt') is not None:
3765-
raise mplDeprecation('vlines now uses a '
3766-
'collections.LineCollection and not a '
3767-
'list of Line2D to draw; see API_CHANGES')
3768-
37693710
self._process_unit_info(xdata=x, ydata=[ymin, ymax], kwargs=kwargs)
37703711

37713712
# We do the conversion first since not all unitized data is uniform
@@ -5970,9 +5911,8 @@ def dopatch(xs, ys):
59705911

59715912
@docstring.dedent_interpd
59725913
def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
5973-
vmin=None, vmax=None, alpha=None, linewidths=None,
5974-
faceted=True, verts=None,
5975-
**kwargs):
5914+
vmin=None, vmax=None, alpha=None, linewidths=None,
5915+
verts=None, **kwargs):
59765916
"""
59775917
Make a scatter plot.
59785918
@@ -6095,13 +6035,15 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
60956035
else:
60966036
colors = mcolors.colorConverter.to_rgba_array(c, alpha)
60976037

6098-
if faceted:
6099-
edgecolors = None
6100-
else:
6101-
edgecolors = 'none'
6102-
warnings.warn(
6103-
'''replace "faceted=False" with "edgecolors='none'"''',
6104-
mplDeprecation) # 2008/04/18
6038+
faceted = kwargs.pop('faceted', None)
6039+
if faceted is not None:
6040+
warnings.warn("The faceted option is deprecated. "
6041+
"Please use edgecolor instead. Will "
6042+
"be remove in 1.4", mplDeprecation)
6043+
if faceted:
6044+
edgecolors = None
6045+
else:
6046+
edgecolors = 'none'
61056047

61066048
# to be API compatible
61076049
if marker is None and not (verts is None):
@@ -7319,6 +7261,9 @@ def pcolor(self, *args, **kwargs):
73197261
cmap = kwargs.pop('cmap', None)
73207262
vmin = kwargs.pop('vmin', None)
73217263
vmax = kwargs.pop('vmax', None)
7264+
if 'shading' in kwargs:
7265+
raise DeprecationWarning("Use edgecolors instead of shading. "
7266+
"Will be removed in 1.4")
73227267
shading = kwargs.pop('shading', 'flat')
73237268

73247269
X, Y, C = self._pcolorargs('pcolor', *args)
@@ -7363,14 +7308,17 @@ def pcolor(self, *args, **kwargs):
73637308
kwargs['linewidths'] = kwargs.pop('linewidth')
73647309
kwargs.setdefault('linewidths', linewidths)
73657310

7311+
73667312
if shading == 'faceted':
73677313
edgecolors = 'k',
73687314
else:
73697315
edgecolors = 'none'
7316+
73707317
if 'edgecolor' in kwargs:
73717318
kwargs['edgecolors'] = kwargs.pop('edgecolor')
73727319
ec = kwargs.setdefault('edgecolors', edgecolors)
73737320

7321+
73747322
# aa setting will default via collections to patch.antialiased
73757323
# unless the boundary is not stroked, in which case the
73767324
# default will be False; with unstroked boundaries, aa
@@ -7893,8 +7841,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
78937841
Either an integer number of bins or a sequence giving the
78947842
bins. If *bins* is an integer, *bins* + 1 bin edges
78957843
will be returned, consistent with :func:`numpy.histogram`
7896-
for numpy version >= 1.3, and with the *new* = True argument
7897-
in earlier versions.
7844+
for numpy version >= 1.3.
78987845
Unequally spaced bins are supported if *bins* is a sequence.
78997846
79007847
*range*:
@@ -8035,11 +7982,6 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
80357982
raise ValueError(
80367983
"orientation kwarg %s is not recognized" % orientation)
80377984

8038-
if kwargs.get('width') is not None:
8039-
raise mplDeprecation(
8040-
'hist now uses the rwidth to give relative width '
8041-
'and not absolute width')
8042-
80437985
if histtype == 'barstacked' and not stacked:
80447986
stacked = True
80457987

@@ -8124,8 +8066,6 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
81248066
# We will handle the normed kwarg within mpl until we
81258067
# get to the point of requiring numpy >= 1.5.
81268068
hist_kwargs = dict(range=bin_range)
8127-
if np.__version__ < "1.3": # version 1.1 and 1.2
8128-
hist_kwargs['new'] = True
81298069

81308070
n = []
81318071
mlast = bottom
@@ -8185,6 +8125,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
81858125

81868126
if align == 'mid' or align == 'edge':
81878127
boffset += 0.5 * totwidth
8128+
81888129
elif align == 'right':
81898130
boffset += totwidth
81908131

@@ -8767,10 +8708,6 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
87678708
:func:`~matplotlib.pyplot.plot`
87688709
For plotting options
87698710
"""
8770-
if precision is None:
8771-
precision = 0
8772-
warnings.warn("Use precision=0 instead of None", mplDeprecation)
8773-
# 2008/10/03
87748711
if marker is None and markersize is None and hasattr(Z, 'tocoo'):
87758712
marker = 's'
87768713
if marker is None and markersize is None:

0 commit comments

Comments
 (0)