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

Skip to content

Commit 84b6f17

Browse files
committed
Merge pull request #394 from WeatherGod/mplot3d/asanyarray
plot_surface now supports any array-like input. Closes #181
2 parents b9569cc + 9bb3520 commit 84b6f17

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
13161316
============= ================================================
13171317
Argument Description
13181318
============= ================================================
1319-
*X*, *Y*, *Z* Data values as numpy.arrays
1319+
*X*, *Y*, *Z* Data values as 2D arrays
13201320
*rstride* Array row stride (step size)
13211321
*cstride* Array column stride (step size)
13221322
*color* Color of the surface patches
@@ -1334,7 +1334,17 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
13341334

13351335
had_data = self.has_data()
13361336

1337+
Z = np.atleast_2d(Z)
13371338
rows, cols = Z.shape
1339+
# TODO: Support masked arrays
1340+
X = np.asarray(X)
1341+
Y = np.asarray(Y)
1342+
# Force X and Y to take the same shape.
1343+
# If they can not be fitted to that shape,
1344+
# then an exception is automatically thrown.
1345+
X.shape = (rows, cols)
1346+
Y.shape = (rows, cols)
1347+
13381348
rstride = kwargs.pop('rstride', 10)
13391349
cstride = kwargs.pop('cstride', 10)
13401350

@@ -1481,7 +1491,7 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
14811491
========== ================================================
14821492
Argument Description
14831493
========== ================================================
1484-
*X*, *Y*, Data values as numpy.arrays
1494+
*X*, *Y*, Data values as 2D arrays
14851495
*Z*
14861496
*rstride* Array row stride (step size)
14871497
*cstride* Array column stride (step size)
@@ -1735,8 +1745,6 @@ def tricontourf(self, X, Y, Z, offset=None, zdir='z', *args, **kwargs):
17351745
========== ================================================
17361746
*X*, *Y*, Data values as numpy.arrays
17371747
*Z*
1738-
*extend3d* Whether to extend contour in 3D (default: False)
1739-
*stride* Stride (step size) for extending contour
17401748
*zdir* The direction to use: x, y or z (default)
17411749
*offset* If specified plot a projection of the contour
17421750
lines on this position in plane normal to zdir
@@ -1749,9 +1757,12 @@ def tricontourf(self, X, Y, Z, offset=None, zdir='z', *args, **kwargs):
17491757
17501758
.. versionadded :: 1.1.0
17511759
'''
1760+
zdir = kwargs.pop('zdir', 'z')
1761+
offset = kwargs.pop('offset', None)
17521762

17531763
had_data = self.has_data()
17541764

1765+
jX, jY, jZ = art3d.rotate_axes(X, Y, Z, zdir)
17551766
cset = Axes.tricontourf(self, X, Y, Z, *args, **kwargs)
17561767
self.add_contourf_set(cset, zdir, offset)
17571768

0 commit comments

Comments
 (0)