Skip to content

Commit

Permalink
Merge pull request #21171 from meeseeksmachine/auto-backport-of-pr-20…
Browse files Browse the repository at this point in the history
…951-on-v3.5.x

Backport PR #20951 on branch v3.5.x ([ENH]: data kwarg support for mplot3d #20912)
  • Loading branch information
timhoffm committed Sep 25, 2021
2 parents 99a681e + 3a365ac commit 48f9d0a
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion lib/mpl_toolkits/mplot3d/axes3d.py
Expand Up @@ -19,7 +19,7 @@

import numpy as np

from matplotlib import _api, cbook, docstring
from matplotlib import _api, cbook, docstring, _preprocess_data
import matplotlib.artist as martist
import matplotlib.axes as maxes
import matplotlib.collections as mcoll
Expand Down Expand Up @@ -2075,6 +2075,7 @@ def add_contourf_set(self, cset, zdir='z', offset=None):
art3d.poly_collection_2d_to_3d(linec, z, zdir=zdir)
linec.set_sort_zpos(z)

@_preprocess_data()
def contour(self, X, Y, Z, *args,
extend3d=False, stride=5, zdir='z', offset=None, **kwargs):
"""
Expand All @@ -2093,6 +2094,9 @@ def contour(self, X, Y, Z, *args,
offset : float, optional
If specified, plot a projection of the contour lines at this
position in a plane normal to zdir.
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
*args, **kwargs
Other arguments are forwarded to `matplotlib.axes.Axes.contour`.
Expand All @@ -2111,6 +2115,7 @@ def contour(self, X, Y, Z, *args,

contour3D = contour

@_preprocess_data()
def tricontour(self, *args,
extend3d=False, stride=5, zdir='z', offset=None, **kwargs):
"""
Expand All @@ -2133,6 +2138,8 @@ def tricontour(self, *args,
offset : float, optional
If specified, plot a projection of the contour lines at this
position in a plane normal to zdir.
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
*args, **kwargs
Other arguments are forwarded to `matplotlib.axes.Axes.tricontour`.
Expand Down Expand Up @@ -2161,6 +2168,7 @@ def tricontour(self, *args,
self.auto_scale_xyz(X, Y, Z, had_data)
return cset

@_preprocess_data()
def contourf(self, X, Y, Z, *args, zdir='z', offset=None, **kwargs):
"""
Create a 3D filled contour plot.
Expand All @@ -2174,6 +2182,8 @@ def contourf(self, X, Y, Z, *args, zdir='z', offset=None, **kwargs):
offset : float, optional
If specified, plot a projection of the contour lines at this
position in a plane normal to zdir.
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
*args, **kwargs
Other arguments are forwarded to `matplotlib.axes.Axes.contourf`.
Expand All @@ -2192,6 +2202,7 @@ def contourf(self, X, Y, Z, *args, zdir='z', offset=None, **kwargs):

contourf3D = contourf

@_preprocess_data()
def tricontourf(self, *args, zdir='z', offset=None, **kwargs):
"""
Create a 3D filled contour plot.
Expand All @@ -2209,6 +2220,8 @@ def tricontourf(self, *args, zdir='z', offset=None, **kwargs):
offset : float, optional
If specified, plot a projection of the contour lines at this
position in a plane normal to zdir.
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
*args, **kwargs
Other arguments are forwarded to
`matplotlib.axes.Axes.tricontourf`.
Expand Down Expand Up @@ -2271,6 +2284,9 @@ def add_collection3d(self, col, zs=0, zdir='z'):
collection = super().add_collection(col)
return collection

@_preprocess_data(replace_names=["xs", "ys", "zs", "s",
"edgecolors", "c", "facecolor",
"facecolors", "color"])
def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
*args, **kwargs):
"""
Expand Down Expand Up @@ -2308,6 +2324,8 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
Whether to shade the scatter markers to give the appearance of
depth. Each call to ``scatter()`` will perform its depthshading
independently.
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
**kwargs
All other arguments are passed on to `~.axes.Axes.scatter`.
Expand Down Expand Up @@ -2342,6 +2360,7 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,

scatter3D = scatter

@_preprocess_data()
def bar(self, left, height, zs=0, zdir='z', *args, **kwargs):
"""
Add 2D bar(s).
Expand All @@ -2357,6 +2376,8 @@ def bar(self, left, height, zs=0, zdir='z', *args, **kwargs):
used for all bars.
zdir : {'x', 'y', 'z'}, default: 'z'
When plotting 2D data, the direction to use as z ('x', 'y' or 'z').
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
**kwargs
Other arguments are forwarded to `matplotlib.axes.Axes.bar`.
Expand Down Expand Up @@ -2393,6 +2414,7 @@ def bar(self, left, height, zs=0, zdir='z', *args, **kwargs):

return patches

@_preprocess_data()
def bar3d(self, x, y, z, dx, dy, dz, color=None,
zsort='average', shade=True, lightsource=None, *args, **kwargs):
"""
Expand Down Expand Up @@ -2441,6 +2463,9 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None,
lightsource : `~matplotlib.colors.LightSource`
The lightsource to use when *shade* is True.
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
**kwargs
Any additional keyword arguments are passed onto
`~.art3d.Poly3DCollection`.
Expand Down Expand Up @@ -2562,6 +2587,7 @@ def set_title(self, label, fontdict=None, loc='center', **kwargs):
self.title.set_y(0.92 * y)
return ret

@_preprocess_data()
def quiver(self, *args,
length=1, arrow_length_ratio=.3, pivot='tail', normalize=False,
**kwargs):
Expand Down Expand Up @@ -2599,6 +2625,9 @@ def quiver(self, *args,
Whether all arrows are normalized to have the same length, or keep
the lengths defined by *u*, *v*, and *w*.
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
**kwargs
Any additional keyword arguments are delegated to
:class:`~matplotlib.collections.LineCollection`
Expand Down Expand Up @@ -2927,6 +2956,7 @@ def permutation_matrices(n):

return polygons

@_preprocess_data(replace_names=["x", "y", "z", "xerr", "yerr", "zerr"])
def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
barsabove=False, errorevery=1, ecolor=None, elinewidth=None,
capsize=None, capthick=None, xlolims=False, xuplims=False,
Expand Down Expand Up @@ -3022,6 +3052,9 @@ def errorbar(self, x, y, z, zerr=None, yerr=None, xerr=None, fmt='',
Other Parameters
----------------
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
**kwargs
All other keyword arguments for styling errorbar lines are passed
`~mpl_toolkits.mplot3d.art3d.Line3DCollection`.
Expand Down Expand Up @@ -3298,6 +3331,7 @@ def get_tightbbox(self, renderer, call_axes_locator=True,
batch.append(axis_bb)
return mtransforms.Bbox.union(batch)

@_preprocess_data()
def stem(self, x, y, z, *, linefmt='C0-', markerfmt='C0o', basefmt='C3-',
bottom=0, label=None, orientation='z'):
"""
Expand Down Expand Up @@ -3349,6 +3383,9 @@ def stem(self, x, y, z, *, linefmt='C0-', markerfmt='C0o', basefmt='C3-',
orientation : {'x', 'y', 'z'}, default: 'z'
The direction along which stems are drawn.
data : indexable object, optional
DATA_PARAMETER_PLACEHOLDER
Returns
-------
`.StemContainer`
Expand Down

0 comments on commit 48f9d0a

Please sign in to comment.