Skip to content

Commit c069b30

Browse files
authored
Handle argument "facecolors=None" correctly in plot_surface() (matplotlib#24727)
* Handle keyword argument "facecolors=None" correctly in plot_surface
1 parent 7c6e057 commit c069b30

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,14 +1598,13 @@ def plot_surface(self, X, Y, Z, *, norm=None, vmin=None,
15981598
rstride = int(max(np.ceil(rows / rcount), 1))
15991599
cstride = int(max(np.ceil(cols / ccount), 1))
16001600

1601-
if 'facecolors' in kwargs:
1602-
fcolors = kwargs.pop('facecolors')
1603-
else:
1601+
fcolors = kwargs.pop('facecolors', None)
1602+
1603+
if fcolors is None:
16041604
color = kwargs.pop('color', None)
16051605
if color is None:
16061606
color = self._get_lines.get_next_color()
16071607
color = np.array(mcolors.to_rgba(color))
1608-
fcolors = None
16091608

16101609
cmap = kwargs.get('cmap', None)
16111610
shade = kwargs.pop('shade', cmap is None)

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,16 @@ def test_surface3d_masked():
608608
ax.view_init(30, -80, 0)
609609

610610

611+
@check_figures_equal(extensions=["png"])
612+
def test_plot_surface_None_arg(fig_test, fig_ref):
613+
x, y = np.meshgrid(np.arange(5), np.arange(5))
614+
z = x + y
615+
ax_test = fig_test.add_subplot(projection='3d')
616+
ax_test.plot_surface(x, y, z, facecolors=None)
617+
ax_ref = fig_ref.add_subplot(projection='3d')
618+
ax_ref.plot_surface(x, y, z)
619+
620+
611621
@mpl3d_image_comparison(['surface3d_masked_strides.png'])
612622
def test_surface3d_masked_strides():
613623
fig = plt.figure()

0 commit comments

Comments
 (0)