X Tutup
Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,8 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):

had_data = self.has_data()

Z = np.atleast_2d(Z)
if Z.ndim != 2:
raise ValueError("Argument Z must be 2-dimensional.")
# TODO: Support masked arrays
X, Y, Z = np.broadcast_arrays(X, Y, Z)
rows, cols = Z.shape
Expand Down Expand Up @@ -1755,7 +1756,8 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
cstride = kwargs.pop("cstride", 1)

had_data = self.has_data()
Z = np.atleast_2d(Z)
if Z.ndim != 2:
raise ValueError("Argument Z must be 2-dimensional.")
# FIXME: Support masked arrays
X, Y, Z = np.broadcast_arrays(X, Y, Z)
rows, cols = Z.shape
Expand Down
12 changes: 11 additions & 1 deletion lib/mpl_toolkits/tests/test_mplot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,17 @@ def test_axes3d_cla():
ax.set_axis_off()
ax.cla() # make sure the axis displayed is 3D (not 2D)


@cleanup
def test_plotsurface_1d_raises():
x = np.linspace(0.5, 10, num=100)
y = np.linspace(0.5, 10, num=100)
X, Y = np.meshgrid(x, y)
z = np.random.randn(100)

fig = plt.figure(figsize=(14,6))
ax = fig.add_subplot(1, 2, 1, projection='3d')
assert_raises(ValueError, ax.plot_surface, X, Y, z)

if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
X Tutup