diff --git a/doc/api/next_api_changes/2018-04-30-ZHD.rst b/doc/api/next_api_changes/2018-04-30-ZHD.rst new file mode 100644 index 000000000000..ac4c1e71bbf3 --- /dev/null +++ b/doc/api/next_api_changes/2018-04-30-ZHD.rst @@ -0,0 +1,13 @@ +Explicit arguments instead of \*args, \*\*kwargs +------------------------------------------------ + +:PEP:`3102` describes keyword-only arguments, which allow Matplotlib +to provide explicit call signatures - where we previously used +``*args, **kwargs`` and ``kwargs.pop``, we can now expose named +arguments. In some places, unknown kwargs were previously ignored but +now raise ``TypeError`` because ``**kwargs`` has been removed. + +- :meth:`matplotlib.axes.Axes.stem` no longer accepts unknown keywords, + and raises ``TypeError`` instead of emitting a deprecation. +- :meth:`mpl_toolkits.axes_grid1.axes_divider.SubPlotDivider` raises + ``TypeError`` instead of ``Exception`` when passed unknown kwargs. diff --git a/doc/devel/contributing.rst b/doc/devel/contributing.rst index 16bf170b5be1..3821297366f1 100644 --- a/doc/devel/contributing.rst +++ b/doc/devel/contributing.rst @@ -394,17 +394,16 @@ on, use the key/value keyword args in the function definition rather than the ``**kwargs`` idiom. In some cases, you may want to consume some keys in the local -function, and let others pass through. You can ``pop`` the ones to be -used locally and pass on the rest. For example, in +function, and let others pass through. Instead of poping arguments to +use off ``**kwargs``, specify them as keyword-only arguments to the local +function. This makes it obvious at a glance which arguments will be +consumed in the function. For example, in :meth:`~matplotlib.axes.Axes.plot`, ``scalex`` and ``scaley`` are local arguments and the rest are passed on as :meth:`~matplotlib.lines.Line2D` keyword arguments:: # in axes/_axes.py - def plot(self, *args, **kwargs): - scalex = kwargs.pop('scalex', True) - scaley = kwargs.pop('scaley', True) - if not self._hold: self.cla() + def plot(self, *args, scalex=True, scaley=True, **kwargs): lines = [] for line in self._get_lines(*args, **kwargs): self.add_line(line) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 94e054847fc5..cbf97d1f68e7 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -1114,7 +1114,7 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1, positional_parameter_names=_plot_args_replacer, label_namer=None) @docstring.dedent_interpd - def plot(self, *args, **kwargs): + def plot(self, *args, scalex=True, scaley=True, **kwargs): """ Plot y versus x as lines and/or markers. @@ -1341,8 +1341,6 @@ def plot(self, *args, **kwargs): 'k^:' # black triangle_up markers connected by a dotted line """ - scalex = kwargs.pop('scalex', True) - scaley = kwargs.pop('scaley', True) lines = [] kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map) @@ -1734,7 +1732,7 @@ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none, #### Specialized plotting @_preprocess_data(replace_names=["x", "y"], label_namer="y") - def step(self, x, y, *args, **kwargs): + def step(self, x, y, *args, where='pre', linestyle='', **kwargs): """ Make a step plot. @@ -1795,12 +1793,10 @@ def step(self, x, y, *args, **kwargs): ----- .. [notes section required to get data note injection right] """ - where = kwargs.pop('where', 'pre') if where not in ('pre', 'post', 'mid'): raise ValueError("'where' argument to step must be " "'pre', 'post' or 'mid'") - usr_linestyle = kwargs.pop('linestyle', '') - kwargs['linestyle'] = 'steps-' + where + usr_linestyle + kwargs['linestyle'] = 'steps-' + where + linestyle return self.plot(x, y, *args, **kwargs) @@ -2268,7 +2264,8 @@ def broken_barh(self, xranges, yrange, **kwargs): return col @_preprocess_data(replace_all_args=True, label_namer=None) - def stem(self, *args, **kwargs): + def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, + bottom=0, label=None): """ Create a stem plot. @@ -2328,15 +2325,6 @@ def stem(self, *args, **kwargs): The label to use for the stems in legends. - Other Parameters - ---------------- - **kwargs - No other parameters are supported. They are currently ignored - silently for backward compatibility. This behavior is deprecated. - Future versions will not accept any other parameters and will - raise a TypeError instead. - - Returns ------- :class:`~matplotlib.container.StemContainer` @@ -2353,41 +2341,18 @@ def stem(self, *args, **kwargs): which inspired this method. """ - - # kwargs handling - # We would like to have a signature with explicit kewords: - # stem(*args, linefmt=None, markerfmt=None, basefmt=None, - # bottom=0, label=None) - # Unfortunately, this is not supported in Python 2.x. There, *args - # can only exist after keyword arguments. - linefmt = kwargs.pop('linefmt', None) - markerfmt = kwargs.pop('markerfmt', None) - basefmt = kwargs.pop('basefmt', None) - bottom = kwargs.pop('bottom', None) - if bottom is None: - bottom = 0 - label = kwargs.pop('label', None) - if kwargs: - warn_deprecated(since='2.2', - message="stem() got an unexpected keyword " - "argument '%s'. This will raise a " - "TypeError in future versions." % ( - next(k for k in kwargs), ) - ) - # Assume there's at least one data array y = np.asarray(args[0]) args = args[1:] # Try a second one try: - second = np.asarray(args[0], dtype=float) - x, y = y, second - args = args[1:] + x, y = y, np.asarray(args[0], dtype=float) except (IndexError, ValueError): # The second array doesn't make sense, or it doesn't exist - second = np.arange(len(y)) - x = second + x = np.arange(len(y)) + else: + args = args[1:] # defaults for formats if linefmt is None: @@ -5242,7 +5207,8 @@ def _pcolorargs(funcname, *args, allmatch=False): @_preprocess_data(label_namer=None) @docstring.dedent_interpd - def pcolor(self, *args, **kwargs): + def pcolor(self, *args, alpha=None, norm=None, cmap=None, vmin=None, + vmax=None, **kwargs): """ Create a pseudocolor plot of a 2-D array. @@ -5381,12 +5347,6 @@ def pcolor(self, *args, **kwargs): not specified, or if ``X`` and ``Y`` have one more row and column than ``C``. """ - alpha = kwargs.pop('alpha', None) - norm = kwargs.pop('norm', None) - cmap = kwargs.pop('cmap', None) - vmin = kwargs.pop('vmin', None) - vmax = kwargs.pop('vmax', None) - X, Y, C = self._pcolorargs('pcolor', *args, allmatch=False) Ny, Nx = X.shape @@ -5488,7 +5448,8 @@ def pcolor(self, *args, **kwargs): @_preprocess_data(label_namer=None) @docstring.dedent_interpd - def pcolormesh(self, *args, **kwargs): + def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None, + vmax=None, shading='flat', antialiased=False, **kwargs): """ Plot a quadrilateral mesh. @@ -5564,13 +5525,7 @@ def pcolormesh(self, *args, **kwargs): %(QuadMesh)s """ - alpha = kwargs.pop('alpha', None) - norm = kwargs.pop('norm', None) - cmap = kwargs.pop('cmap', None) - vmin = kwargs.pop('vmin', None) - vmax = kwargs.pop('vmax', None) - shading = kwargs.pop('shading', 'flat').lower() - antialiased = kwargs.pop('antialiased', False) + shading = shading.lower() kwargs.setdefault('edgecolors', 'None') allmatch = (shading == 'gouraud') @@ -5625,7 +5580,8 @@ def pcolormesh(self, *args, **kwargs): @_preprocess_data(label_namer=None) @docstring.dedent_interpd - def pcolorfast(self, *args, **kwargs): + def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None, + vmax=None, **kwargs): """ pseudocolor plot of a 2-D array @@ -5707,11 +5663,6 @@ def pcolorfast(self, *args, **kwargs): collection in the general quadrilateral case. """ - alpha = kwargs.pop('alpha', None) - norm = kwargs.pop('norm', None) - cmap = kwargs.pop('cmap', None) - vmin = kwargs.pop('vmin', None) - vmax = kwargs.pop('vmax', None) if norm is not None and not isinstance(norm, mcolors.Normalize): raise ValueError( "'norm' must be an instance of 'mcolors.Normalize'") diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 5e9aed3cf332..030e21f7687f 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2084,7 +2084,8 @@ def _get_output_canvas(self, fmt): .format(fmt, ", ".join(sorted(self.get_supported_filetypes())))) def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None, - orientation='portrait', format=None, **kwargs): + orientation='portrait', format=None, + *, bbox_inches=None, **kwargs): """ Render the figure to hardcopy. Set the figure patch face and edge colors. This is useful because some of the GUIs have a gray figure @@ -2165,7 +2166,6 @@ def print_figure(self, filename, dpi=None, facecolor=None, edgecolor=None, self.figure.set_facecolor(facecolor) self.figure.set_edgecolor(edgecolor) - bbox_inches = kwargs.pop("bbox_inches", None) if bbox_inches is None: bbox_inches = rcParams['savefig.bbox'] diff --git a/lib/matplotlib/backends/backend_ps.py b/lib/matplotlib/backends/backend_ps.py index 58ffbd400e69..e02b37df7c5c 100644 --- a/lib/matplotlib/backends/backend_ps.py +++ b/lib/matplotlib/backends/backend_ps.py @@ -930,8 +930,12 @@ def print_ps(self, outfile, *args, **kwargs): def print_eps(self, outfile, *args, **kwargs): return self._print_ps(outfile, 'eps', *args, **kwargs) - def _print_ps(self, outfile, format, *args, **kwargs): - papertype = kwargs.pop("papertype", rcParams['ps.papersize']) + def _print_ps(self, outfile, format, *args, + papertype=None, dpi=72, facecolor='w', edgecolor='w', + orientation='portrait', + **kwargs): + if papertype is None: + papertype = rcParams['ps.papersize'] papertype = papertype.lower() if papertype == 'auto': pass @@ -939,22 +943,19 @@ def _print_ps(self, outfile, format, *args, **kwargs): raise RuntimeError('%s is not a valid papertype. Use one of %s' % (papertype, ', '.join(papersize))) - orientation = kwargs.pop("orientation", "portrait").lower() + orientation = orientation.lower() if orientation == 'landscape': isLandscape = True elif orientation == 'portrait': isLandscape = False else: raise RuntimeError('Orientation must be "portrait" or "landscape"') self.figure.set_dpi(72) # Override the dpi kwarg - imagedpi = kwargs.pop("dpi", 72) - facecolor = kwargs.pop("facecolor", "w") - edgecolor = kwargs.pop("edgecolor", "w") if rcParams['text.usetex']: - self._print_figure_tex(outfile, format, imagedpi, facecolor, edgecolor, + self._print_figure_tex(outfile, format, dpi, facecolor, edgecolor, orientation, isLandscape, papertype, **kwargs) else: - self._print_figure(outfile, format, imagedpi, facecolor, edgecolor, + self._print_figure(outfile, format, dpi, facecolor, edgecolor, orientation, isLandscape, papertype, **kwargs) diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index 1757abbb18b9..eb2b7172fb80 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -1323,7 +1323,7 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15, @docstring.Substitution(make_axes_kw_doc) -def make_axes_gridspec(parent, **kw): +def make_axes_gridspec(parent, *, fraction=0.15, shrink=1.0, aspect=20, **kw): ''' Resize and reposition a parent axes, and return a child axes suitable for a colorbar. This function is similar to @@ -1360,10 +1360,6 @@ def make_axes_gridspec(parent, **kw): orientation = kw.setdefault('orientation', 'vertical') kw['ticklocation'] = 'auto' - fraction = kw.pop('fraction', 0.15) - shrink = kw.pop('shrink', 1.0) - aspect = kw.pop('aspect', 20) - x1 = 1 - fraction # for shrinking diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index 820fb7724f0e..e3c741bed91d 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -791,7 +791,12 @@ class ContourSet(cm.ScalarMappable, ContourLabeler): levels for filled contours. See :meth:`_process_colors`. """ - def __init__(self, ax, *args, **kwargs): + def __init__(self, ax, *args, + levels=None, filled=False, linewidths=None, linestyles=None, + alpha=None, origin=None, extent=None, + cmap=None, colors=None, norm=None, vmin=None, vmax=None, + extend='neither', antialiased=None, + **kwargs): """ Draw contour lines or filled regions, depending on whether keyword arg *filled* is ``False`` (default) or ``True``. @@ -837,23 +842,17 @@ def __init__(self, ax, *args, **kwargs): `~axes.Axes.contour`. """ self.ax = ax - self.levels = kwargs.pop('levels', None) - self.filled = kwargs.pop('filled', False) - self.linewidths = kwargs.pop('linewidths', None) - self.linestyles = kwargs.pop('linestyles', None) - + self.levels = levels + self.filled = filled + self.linewidths = linewidths + self.linestyles = linestyles self.hatches = kwargs.pop('hatches', [None]) - - self.alpha = kwargs.pop('alpha', None) - self.origin = kwargs.pop('origin', None) - self.extent = kwargs.pop('extent', None) - cmap = kwargs.pop('cmap', None) - self.colors = kwargs.pop('colors', None) - norm = kwargs.pop('norm', None) - vmin = kwargs.pop('vmin', None) - vmax = kwargs.pop('vmax', None) - self.extend = kwargs.pop('extend', 'neither') - self.antialiased = kwargs.pop('antialiased', None) + self.alpha = alpha + self.origin = origin + self.extent = extent + self.colors = colors + self.extend = extend + self.antialiased = antialiased if self.antialiased is None and self.filled: self.antialiased = False # eliminate artifacts; we are not # stroking the boundaries. diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index da1d07d91c36..e2fca38313a2 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -1758,7 +1758,7 @@ def add_axobserver(self, func): """Whenever the axes state change, ``func(self)`` will be called.""" self._axobservers.append(func) - def savefig(self, fname, **kwargs): + def savefig(self, fname, *, frameon=None, transparent=None, **kwargs): """ Save the current figure. @@ -1842,9 +1842,10 @@ def savefig(self, fname, **kwargs): """ kwargs.setdefault('dpi', rcParams['savefig.dpi']) - frameon = kwargs.pop('frameon', rcParams['savefig.frameon']) - transparent = kwargs.pop('transparent', - rcParams['savefig.transparent']) + if frameon is None: + frameon = rcParams['savefig.frameon'] + if transparent is None: + transparent = rcParams['savefig.transparent'] if transparent: kwargs.setdefault('facecolor', 'none') diff --git a/lib/matplotlib/quiver.py b/lib/matplotlib/quiver.py index dec116363771..65a34c0874cb 100644 --- a/lib/matplotlib/quiver.py +++ b/lib/matplotlib/quiver.py @@ -238,17 +238,20 @@ class QuiverKey(martist.Artist): valign = {'N': 'bottom', 'S': 'top', 'E': 'center', 'W': 'center'} pivot = {'N': 'middle', 'S': 'middle', 'E': 'tip', 'W': 'tail'} - def __init__(self, Q, X, Y, U, label, **kw): + def __init__(self, Q, X, Y, U, label, + *, angle=0, coordinates='axes', color=None, labelsep=0.1, + labelpos='N', labelcolor=None, fontproperties=None, + **kw): martist.Artist.__init__(self) self.Q = Q self.X = X self.Y = Y self.U = U - self.angle = kw.pop('angle', 0) - self.coord = kw.pop('coordinates', 'axes') - self.color = kw.pop('color', None) + self.angle = angle + self.coord = coordinates + self.color = color self.label = label - self._labelsep_inches = kw.pop('labelsep', 0.1) + self._labelsep_inches = labelsep self.labelsep = (self._labelsep_inches * Q.ax.figure.dpi) # try to prevent closure over the real self @@ -266,9 +269,9 @@ def on_dpi_change(fig): self._cid = Q.ax.figure.callbacks.connect('dpi_changed', on_dpi_change) - self.labelpos = kw.pop('labelpos', 'N') - self.labelcolor = kw.pop('labelcolor', None) - self.fontproperties = kw.pop('fontproperties', dict()) + self.labelpos = labelpos + self.labelcolor = labelcolor + self.fontproperties = fontproperties or dict() self.kw = kw _fp = self.fontproperties # boxprops = dict(facecolor='red') @@ -426,10 +429,13 @@ class Quiver(mcollections.PolyCollection): in the draw() method. """ - _PIVOT_VALS = ('tail', 'mid', 'middle', 'tip') + _PIVOT_VALS = ('tail', 'middle', 'tip') @docstring.Substitution(_quiver_doc) - def __init__(self, ax, *args, **kw): + def __init__(self, ax, *args, + scale=None, headwidth=3, headlength=5, headaxislength=4.5, + minshaft=1, minlength=1, units='width', scale_units=None, + angles='uv', width=None, color='k', pivot='tail', **kw): """ The constructor takes one required argument, an Axes instance, followed by the args and kwargs described @@ -442,28 +448,25 @@ def __init__(self, ax, *args, **kw): self.Y = Y self.XY = np.column_stack((X, Y)) self.N = len(X) - self.scale = kw.pop('scale', None) - self.headwidth = kw.pop('headwidth', 3) - self.headlength = float(kw.pop('headlength', 5)) - self.headaxislength = kw.pop('headaxislength', 4.5) - self.minshaft = kw.pop('minshaft', 1) - self.minlength = kw.pop('minlength', 1) - self.units = kw.pop('units', 'width') - self.scale_units = kw.pop('scale_units', None) - self.angles = kw.pop('angles', 'uv') - self.width = kw.pop('width', None) - self.color = kw.pop('color', 'k') - - pivot = kw.pop('pivot', 'tail').lower() - # validate pivot - if pivot not in self._PIVOT_VALS: + self.scale = scale + self.headwidth = headwidth + self.headlength = float(headlength) + self.headaxislength = headaxislength + self.minshaft = minshaft + self.minlength = minlength + self.units = units + self.scale_units = scale_units + self.angles = angles + self.width = width + self.color = color + + if pivot.lower() == 'mid': + pivot = 'middle' + self.pivot = pivot.lower() + if self.pivot not in self._PIVOT_VALS: raise ValueError( 'pivot must be one of {keys}, you passed {inp}'.format( keys=self._PIVOT_VALS, inp=pivot)) - # normalize to 'middle' - if pivot == 'mid': - pivot = 'middle' - self.pivot = pivot self.transform = kw.pop('transform', ax.transData) kw.setdefault('facecolors', self.color) @@ -902,23 +905,26 @@ class Barbs(mcollections.PolyCollection): # 1 triangle and a series of lines. It works fine as far as I can tell # however. @docstring.interpd - def __init__(self, ax, *args, **kw): + def __init__(self, ax, *args, + pivot='tip', length=7, barbcolor=None, flagcolor=None, + sizes=None, fill_empty=False, barb_increments=None, + rounding=True, flip_barb=False, **kw): """ The constructor takes one required argument, an Axes instance, followed by the args and kwargs described by the following pylab interface documentation: %(barbs_doc)s """ - self._pivot = kw.pop('pivot', 'tip') - self._length = kw.pop('length', 7) - barbcolor = kw.pop('barbcolor', None) - flagcolor = kw.pop('flagcolor', None) - self.sizes = kw.pop('sizes', dict()) - self.fill_empty = kw.pop('fill_empty', False) - self.barb_increments = kw.pop('barb_increments', dict()) - self.rounding = kw.pop('rounding', True) - self.flip = kw.pop('flip_barb', False) + self.sizes = sizes or dict() + self.fill_empty = fill_empty + self.barb_increments = barb_increments or dict() + self.rounding = rounding + self.flip = flip_barb transform = kw.pop('transform', ax.transData) + self._pivot = pivot + self._length = length + barbcolor = barbcolor + flagcolor = flagcolor # Flagcolor and barbcolor provide convenience parameters for # setting the facecolor and edgecolor, respectively, of the barb diff --git a/lib/matplotlib/stackplot.py b/lib/matplotlib/stackplot.py index eec654843aa4..0f8b72b1203a 100644 --- a/lib/matplotlib/stackplot.py +++ b/lib/matplotlib/stackplot.py @@ -11,7 +11,9 @@ __all__ = ['stackplot'] -def stackplot(axes, x, *args, **kwargs): +def stackplot(axes, x, *args, + labels=(), colors=None, baseline='zero', + **kwargs): """ Draws a stacked area plot. @@ -58,13 +60,10 @@ def stackplot(axes, x, *args, **kwargs): y = np.row_stack(args) - labels = iter(kwargs.pop('labels', [])) - - colors = kwargs.pop('colors', None) + labels = iter(labels) if colors is not None: axes.set_prop_cycle(color=colors) - baseline = kwargs.pop('baseline', 'zero') # Assume data passed has not been 'stacked', so stack it here. # We'll need a float buffer for the upcoming calculations. stack = np.cumsum(y, axis=0, dtype=np.promote_types(y.dtype, np.float32)) diff --git a/lib/matplotlib/tri/tripcolor.py b/lib/matplotlib/tri/tripcolor.py index d384a9d4808f..f72ba8c520fc 100644 --- a/lib/matplotlib/tri/tripcolor.py +++ b/lib/matplotlib/tri/tripcolor.py @@ -5,7 +5,8 @@ from matplotlib.tri.triangulation import Triangulation -def tripcolor(ax, *args, **kwargs): +def tripcolor(ax, *args, alpha=1.0, norm=None, cmap=None, vmin=None, + vmax=None, shading='flat', facecolors=None, **kwargs): """ Create a pseudocolor plot of an unstructured triangular grid. @@ -45,14 +46,6 @@ def tripcolor(ax, *args, **kwargs): The remaining kwargs are the same as for :meth:`~matplotlib.axes.Axes.pcolor`. """ - alpha = kwargs.pop('alpha', 1.0) - norm = kwargs.pop('norm', None) - cmap = kwargs.pop('cmap', None) - vmin = kwargs.pop('vmin', None) - vmax = kwargs.pop('vmax', None) - shading = kwargs.pop('shading', 'flat') - facecolors = kwargs.pop('facecolors', None) - if shading not in ['flat', 'gouraud']: raise ValueError("shading must be one of ['flat', 'gouraud'] " "not {0}".format(shading)) diff --git a/lib/mpl_toolkits/axes_grid1/axes_divider.py b/lib/mpl_toolkits/axes_grid1/axes_divider.py index fa6f07a74332..fa96eebc9a18 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_divider.py +++ b/lib/mpl_toolkits/axes_grid1/axes_divider.py @@ -359,7 +359,8 @@ class SubplotDivider(Divider): The Divider class whose rectangle area is specified as a subplot geometry. """ - def __init__(self, fig, *args, **kwargs): + def __init__(self, fig, *args, horizontal=None, vertical=None, + aspect=None, anchor='C'): """ Parameters ---------- @@ -417,15 +418,7 @@ def __init__(self, fig, *args, **kwargs): pos = self.figbox.bounds - horizontal = kwargs.pop("horizontal", []) - vertical = kwargs.pop("vertical", []) - aspect = kwargs.pop("aspect", None) - anchor = kwargs.pop("anchor", "C") - - if kwargs: - raise Exception("") - - Divider.__init__(self, fig, pos, horizontal, vertical, + Divider.__init__(self, fig, pos, horizontal or [], vertical or [], aspect=aspect, anchor=anchor) def get_position(self): diff --git a/lib/mpl_toolkits/axes_grid1/colorbar.py b/lib/mpl_toolkits/axes_grid1/colorbar.py index 3a76914a6fb3..b5e28d9fa0aa 100644 --- a/lib/mpl_toolkits/axes_grid1/colorbar.py +++ b/lib/mpl_toolkits/axes_grid1/colorbar.py @@ -753,7 +753,7 @@ def update_bruteforce(self, mappable): self.add_lines(mappable) @docstring.Substitution(make_axes_kw_doc) -def make_axes(parent, **kw): +def make_axes(parent, *, fraction=0.15, shrink=1.0, aspect=20, **kw): ''' Resize and reposition a parent axes, and return a child axes suitable for a colorbar @@ -774,9 +774,6 @@ def make_axes(parent, **kw): Returns (cax, kw), the child axes and the reduced kw dictionary. ''' orientation = kw.setdefault('orientation', 'vertical') - fraction = kw.pop('fraction', 0.15) - shrink = kw.pop('shrink', 1.0) - aspect = kw.pop('aspect', 20) #pb = transforms.PBox(parent.get_position()) pb = parent.get_position(original=True).frozen() if orientation == 'vertical': diff --git a/lib/mpl_toolkits/mplot3d/art3d.py b/lib/mpl_toolkits/mplot3d/art3d.py index 4c58be8cdb52..543e1b4c7a7d 100644 --- a/lib/mpl_toolkits/mplot3d/art3d.py +++ b/lib/mpl_toolkits/mplot3d/art3d.py @@ -267,9 +267,7 @@ class Patch3D(Patch): 3D patch object. """ - def __init__(self, *args, **kwargs): - zs = kwargs.pop('zs', []) - zdir = kwargs.pop('zdir', 'z') + def __init__(self, *args, zs=(), zdir='z', **kwargs): Patch.__init__(self, *args, **kwargs) self.set_3d_properties(zs, zdir) @@ -300,9 +298,7 @@ class PathPatch3D(Patch3D): 3D PathPatch object. """ - def __init__(self, path, **kwargs): - zs = kwargs.pop('zs', []) - zdir = kwargs.pop('zdir', 'z') + def __init__(self, path, *, zs=(), zdir='z', **kwargs): Patch.__init__(self, **kwargs) self.set_3d_properties(path, zs, zdir) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index ab754ce7bf79..f0e4d7984956 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -1528,7 +1528,7 @@ def text(self, x, y, z, s, zdir=None, **kwargs): text3D = text text2D = Axes.text - def plot(self, xs, ys, *args, **kwargs): + def plot(self, xs, ys, *args, zdir='z', **kwargs): ''' Plot 2D or 3D data. @@ -1558,7 +1558,6 @@ def plot(self, xs, ys, *args, **kwargs): raise TypeError("plot() for multiple values for argument 'z'") else: zs = kwargs.pop('zs', 0) - zdir = kwargs.pop('zdir', 'z') # Match length zs = np.broadcast_to(zs, len(xs)) @@ -1573,7 +1572,8 @@ def plot(self, xs, ys, *args, **kwargs): plot3D = plot - def plot_surface(self, X, Y, Z, *args, **kwargs): + def plot_surface(self, X, Y, Z, *args, norm=None, vmin=None, + vmax=None, lightsource=None, **kwargs): """ Create a surface plot. @@ -1672,12 +1672,7 @@ def plot_surface(self, X, Y, Z, *args, **kwargs): fcolors = None cmap = kwargs.get('cmap', None) - norm = kwargs.pop('norm', None) - vmin = kwargs.pop('vmin', None) - vmax = kwargs.pop('vmax', None) - linewidth = kwargs.get('linewidth', None) shade = kwargs.pop('shade', cmap is None) - lightsource = kwargs.pop('lightsource', None) # Shade the data if shade and cmap is not None and fcolors is not None: @@ -1923,7 +1918,8 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs): return linec - def plot_trisurf(self, *args, **kwargs): + def plot_trisurf(self, *args, color=None, norm=None, vmin=None, vmax=None, + lightsource=None, **kwargs): """ ============= ================================================ Argument Description @@ -1975,18 +1971,12 @@ def plot_trisurf(self, *args, **kwargs): had_data = self.has_data() # TODO: Support custom face colours - color = kwargs.pop('color', None) if color is None: color = self._get_lines.get_next_color() color = np.array(mcolors.to_rgba(color)) cmap = kwargs.get('cmap', None) - norm = kwargs.pop('norm', None) - vmin = kwargs.pop('vmin', None) - vmax = kwargs.pop('vmax', None) - linewidth = kwargs.get('linewidth', None) shade = kwargs.pop('shade', cmap is None) - lightsource = kwargs.pop('lightsource', None) tri, args, kwargs = Triangulation.get_from_args_and_kwargs(*args, **kwargs) if 'Z' in kwargs: