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

Skip to content

Commit 2798e47

Browse files
committed
Merge pull request #1074 from WeatherGod/mplot3d/input_broadcast2
Added broadcasting support in some mplot3d methods
2 parents 551f11b + 6ca36ef commit 2798e47

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,15 +1352,9 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
13521352
had_data = self.has_data()
13531353

13541354
Z = np.atleast_2d(Z)
1355-
rows, cols = Z.shape
13561355
# TODO: Support masked arrays
1357-
X = np.asarray(X)
1358-
Y = np.asarray(Y)
1359-
# Force X and Y to take the same shape.
1360-
# If they can not be fitted to that shape,
1361-
# then an exception is automatically thrown.
1362-
X.shape = (rows, cols)
1363-
Y.shape = (rows, cols)
1356+
X, Y, Z = np.broadcast_arrays(X, Y, Z)
1357+
rows, cols = Z.shape
13641358

13651359
rstride = kwargs.pop('rstride', 10)
13661360
cstride = kwargs.pop('cstride', 10)
@@ -1526,14 +1520,8 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
15261520
had_data = self.has_data()
15271521
Z = np.atleast_2d(Z)
15281522
# FIXME: Support masked arrays
1529-
X = np.asarray(X)
1530-
Y = np.asarray(Y)
1523+
X, Y, Z = np.broadcast_arrays(X, Y, Z)
15311524
rows, cols = Z.shape
1532-
# Force X and Y to take the same shape.
1533-
# If they can not be fitted to that shape,
1534-
# then an exception is automatically thrown.
1535-
X.shape = (rows, cols)
1536-
Y.shape = (rows, cols)
15371525

15381526
# We want two sets of lines, one running along the "rows" of
15391527
# Z and another set of lines running along the "columns" of Z.

0 commit comments

Comments
 (0)