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

Skip to content

removed deprecated methods from the axes module. #1568

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 4 commits into from
Jan 16, 2013
Merged
Changes from all commits
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
141 changes: 39 additions & 102 deletions lib/matplotlib/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,6 @@ def _process_plot_format(fmt):
return linestyle, marker, color


def set_default_color_cycle(clist):
"""
Change the default cycle of colors that will be used by the plot
command. This must be called before creating the
:class:`Axes` to which it will apply; it will
apply to all future axes.

*clist* is a sequence of mpl color specifiers.

See also: :meth:`~matplotlib.axes.Axes.set_color_cycle`.

.. Note:: Deprecated 2010/01/03.
Set rcParams['axes.color_cycle'] directly.

"""
rcParams['axes.color_cycle'] = clist
warnings.warn("Set rcParams['axes.color_cycle'] directly", mplDeprecation)


class _process_plot_var_args(object):
"""
Process variable length arguments to the plot command, so that
Expand Down Expand Up @@ -282,12 +263,11 @@ def _makefill(self, x, y, kw, kwargs):
facecolor = kw['color']
except KeyError:
facecolor = self.color_cycle.next()
seg = mpatches.Polygon(np.hstack(
(x[:, np.newaxis], y[:, np.newaxis])),
facecolor=facecolor,
fill=True,
closed=kw['closed']
)
seg = mpatches.Polygon(np.hstack((x[:, np.newaxis],
y[:, np.newaxis])),
facecolor=facecolor,
fill=True,
closed=kw['closed'])
self.set_patchprops(seg, **kwargs)
return seg

Expand Down Expand Up @@ -586,9 +566,9 @@ def _set_lim_and_transforms(self):
self.transData = self.transScale + (self.transLimits + self.transAxes)

self._xaxis_transform = mtransforms.blended_transform_factory(
self.transData, self.transAxes)
self.transData, self.transAxes)
self._yaxis_transform = mtransforms.blended_transform_factory(
self.transAxes, self.transData)
self.transAxes, self.transData)

def get_xaxis_transform(self, which='grid'):
"""
Expand Down Expand Up @@ -1067,11 +1047,16 @@ def set_aspect(self, aspect, adjustable=None, anchor=None):
etc.
===== =====================

.. deprecated:: 1.2
Copy link
Member

Choose a reason for hiding this comment

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

If we're deprecating this in 1.2, should this PR be targeting the v1.2.x instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was deprecated before: the only "problem" is that it was mention in the documentation, but no deprecation warning was raised. I'm not sure how to use this documentation tag: should I put the version were it was tag as being deprecated, or the version were we target the removal of the option ?

Copy link
Member

Choose a reason for hiding this comment

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

Aha... I see. Ok. No, I think you have used the tag correctly.

the option 'normal' for aspect is deprecated. Use 'auto' instead.
"""
if aspect in ('normal', 'auto'):
if aspect == 'normal':
warnings.warn("Use 'auto' instead of 'normal' for aspect. Will "
"be removed in 1.4.x", mplDeprecation)
self._aspect = 'auto'
elif aspect == 'equal':
self._aspect = 'equal'

elif aspect in ('equal', 'auto'):
self._aspect = aspect
else:
self._aspect = float(aspect) # raise ValueError if necessary

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

return v

def get_child_artists(self):
"""
Return a list of artists the axes contains.

.. deprecated:: 0.98
"""
raise mplDeprecation('Use get_children instead')

def get_frame(self):
"""Return the axes Rectangle frame"""
warnings.warn('use ax.patch instead', mplDeprecation)
Expand Down Expand Up @@ -3108,30 +3085,6 @@ def set_cursor_props(self, *args):
c = mcolors.colorConverter.to_rgba(c)
self._cursorProps = lw, c

def connect(self, s, func):
"""
Register observers to be notified when certain events occur. Register
with callback functions with the following signatures. The function
has the following signature::

func(ax) # where ax is the instance making the callback.

The following events can be connected to:

'xlim_changed','ylim_changed'

The connection id is is returned - you can use this with
disconnect to disconnect from the axes event

"""
raise mplDeprecation('use the callbacks CallbackRegistry instance '
'instead')

def disconnect(self, cid):
"""disconnect from the Axes event."""
raise mplDeprecation('use the callbacks CallbackRegistry instance '
'instead')

def get_children(self):
"""return a list of child artists"""
children = []
Expand Down Expand Up @@ -3180,9 +3133,6 @@ def pick(self, *args):
each child artist will fire a pick event if mouseevent is over
the artist and the artist has picker set
"""
if len(args) > 1:
raise mplDeprecation('New pick API implemented -- '
'see API_CHANGES in the src distribution')
martist.Artist.pick(self, args[0])

### Labelling
Expand Down Expand Up @@ -3679,10 +3629,6 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',

.. plot:: mpl_examples/pylab_examples/hline_demo.py
"""
if kwargs.get('fmt') is not None:
raise mplDeprecation('hlines now uses a '
'collections.LineCollection and not a '
'list of Line2D to draw; see API_CHANGES')

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

if kwargs.get('fmt') is not None:
raise mplDeprecation('vlines now uses a '
'collections.LineCollection and not a '
'list of Line2D to draw; see API_CHANGES')

self._process_unit_info(xdata=x, ydata=[ymin, ymax], kwargs=kwargs)

# We do the conversion first since not all unitized data is uniform
Expand Down Expand Up @@ -4476,7 +4417,8 @@ def legend(self, *args, **kwargs):
instance. If *prop* is a dictionary, a new instance will be
created with *prop*. If *None*, use rc settings.

*fontsize*: [ size in points | 'xx-small' | 'x-small' | 'small' | 'medium' | 'large' | 'x-large' | 'xx-large' ]
*fontsize*: [size in points | 'xx-small' | 'x-small' | 'small' |
'medium' | 'large' | 'x-large' | 'xx-large']
Set the font size. May be either a size string, relative to
the default font size, or an absolute font size in points. This
argument is only used if prop is not specified.
Expand Down Expand Up @@ -5498,7 +5440,6 @@ def xywhere(xs, ys, mask):
if 'zorder' in kwargs:
plot_kw['zorder'] = kwargs['zorder']


if xerr is not None:
if (iterable(xerr) and len(xerr) == 2 and
iterable(xerr[0]) and iterable(xerr[1])):
Expand Down Expand Up @@ -5970,9 +5911,8 @@ def dopatch(xs, ys):

@docstring.dedent_interpd
def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
vmin=None, vmax=None, alpha=None, linewidths=None,
faceted=True, verts=None,
**kwargs):
vmin=None, vmax=None, alpha=None, linewidths=None,
verts=None, **kwargs):
"""
Make a scatter plot.

Expand Down Expand Up @@ -6095,13 +6035,16 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
else:
colors = mcolors.colorConverter.to_rgba_array(c, alpha)

if faceted:
edgecolors = None
else:
edgecolors = 'none'
warnings.warn(
'''replace "faceted=False" with "edgecolors='none'"''',
mplDeprecation) # 2008/04/18
faceted = kwargs.pop('faceted', None)
edgecolors = kwargs.get('edgecolors', None)
if faceted is not None:
warnings.warn("The faceted option is deprecated. "
"Please use edgecolor instead. Will "
"be remove in 1.4", mplDeprecation)
if faceted:
edgecolors = None
else:
edgecolors = 'none'
Copy link
Member

Choose a reason for hiding this comment

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

In the scatter test, this code never gets executed and edgecolors doesn't get set.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've fixed the problem. I think there was a bug before, as edgecolors was always set from the argument faceted, instead of being fetched from the kwargs.

I also think we need to consider moving it from kwargs to a named argument. What do you think?

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 that, to be consistent with the other pyplot functions, we should leave it as a kwarg and perhaps formulate an MEP to overhaul the kwargs if there is a consensus for that.


# to be API compatible
if marker is None and not (verts is None):
Expand Down Expand Up @@ -6615,9 +6558,10 @@ def arrow(self, x, y, dx, dy, **kwargs):
Draws arrow on specified axis from (*x*, *y*) to (*x* + *dx*,
*y* + *dy*). Uses FancyArrow patch to construct the arrow.

The resulting arrow is affected by the axes aspect ratio and limits. This
may produce an arrow whose head is not square with its stem. To create
an arrow whose head is square with its stem, use :meth:`annotate`.
The resulting arrow is affected by the axes aspect ratio and limits.
This may produce an arrow whose head is not square with its stem. To
create an arrow whose head is square with its stem, use
:meth:`annotate`.

Optional kwargs control the arrow construction and properties:

Expand Down Expand Up @@ -7319,6 +7263,9 @@ def pcolor(self, *args, **kwargs):
cmap = kwargs.pop('cmap', None)
vmin = kwargs.pop('vmin', None)
vmax = kwargs.pop('vmax', None)
if 'shading' in kwargs:
warnings.warn("Use edgecolors instead of shading. "
"Will be removed in 1.4", mplDeprecation)
shading = kwargs.pop('shading', 'flat')

X, Y, C = self._pcolorargs('pcolor', *args)
Expand Down Expand Up @@ -7367,6 +7314,7 @@ def pcolor(self, *args, **kwargs):
edgecolors = 'k',
else:
edgecolors = 'none'

if 'edgecolor' in kwargs:
kwargs['edgecolors'] = kwargs.pop('edgecolor')
ec = kwargs.setdefault('edgecolors', edgecolors)
Expand Down Expand Up @@ -7893,8 +7841,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
Either an integer number of bins or a sequence giving the
bins. If *bins* is an integer, *bins* + 1 bin edges
will be returned, consistent with :func:`numpy.histogram`
for numpy version >= 1.3, and with the *new* = True argument
in earlier versions.
for numpy version >= 1.3.
Unequally spaced bins are supported if *bins* is a sequence.

*range*:
Expand Down Expand Up @@ -8035,11 +7982,6 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
raise ValueError(
"orientation kwarg %s is not recognized" % orientation)

if kwargs.get('width') is not None:
raise mplDeprecation(
'hist now uses the rwidth to give relative width '
'and not absolute width')

if histtype == 'barstacked' and not stacked:
stacked = True

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

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

if align == 'mid' or align == 'edge':
boffset += 0.5 * totwidth

elif align == 'right':
boffset += totwidth

Expand Down Expand Up @@ -8767,10 +8708,6 @@ def spy(self, Z, precision=0, marker=None, markersize=None,
:func:`~matplotlib.pyplot.plot`
For plotting options
"""
if precision is None:
precision = 0
warnings.warn("Use precision=0 instead of None", mplDeprecation)
# 2008/10/03
if marker is None and markersize is None and hasattr(Z, 'tocoo'):
marker = 's'
if marker is None and markersize is None:
Expand Down