From d8ca49c835eb7c66df8f33a6e64d319a8e0fb9e0 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 27 Aug 2016 16:58:07 -0400 Subject: [PATCH 1/2] FIX: default color handling in bar3D If color not specified (default to `None`), get the next color from the axes color cycle. closes #6989 --- lib/mpl_toolkits/mplot3d/axes3d.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index ce969545f28c..8d7181423299 100755 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -2443,9 +2443,9 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None, facecolors = [] if color is None: - # no color specified - facecolors = [None] * len(x) - elif len(color) == len(x): + color = [self._get_lines.get_next_color()] + + if len(color) == len(x): # bar colors specified, need to expand to number of faces for c in color: facecolors.extend([c] * 6) From e0dbfdfe0f1707ec6a3ccfedad3cac3b36099263 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 27 Aug 2016 19:43:25 -0400 Subject: [PATCH 2/2] TST: add smoke test for default color in bar3D --- lib/mpl_toolkits/tests/test_mplot3d.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/mpl_toolkits/tests/test_mplot3d.py b/lib/mpl_toolkits/tests/test_mplot3d.py index 96070a8ed436..530d0e121736 100644 --- a/lib/mpl_toolkits/tests/test_mplot3d.py +++ b/lib/mpl_toolkits/tests/test_mplot3d.py @@ -20,6 +20,19 @@ def test_bar3d(): ax.bar(xs, ys, zs=z, zdir='y', color=cs, alpha=0.8) +@cleanup +def test_bar3d_dflt_smoke(): + fig = plt.figure() + ax = fig.add_subplot(111, projection='3d') + x = np.arange(4) + y = np.arange(5) + x2d, y2d = np.meshgrid(x, y) + x2d, y2d = x2d.ravel(), y2d.ravel() + z = x2d + y2d + ax.bar3d(x2d, y2d, x2d * 0, 1, 1, z) + fig.canvas.draw() + + @image_comparison(baseline_images=['contour3d'], remove_text=True) def test_contour3d(): fig = plt.figure()