diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index 584e12461d6d..ebf03f7bf20f 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -2507,13 +2507,15 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None, if color is None: color = [self._get_patches_for_fill.get_next_color()] + color = list(mcolors.to_rgba_array(color)) + if len(color) == len(x): # bar colors specified, need to expand to number of faces for c in color: facecolors.extend([c] * 6) else: # a single color specified, or face colors specified explicitly - facecolors = list(mcolors.to_rgba_array(color)) + facecolors = color if len(facecolors) < len(x): facecolors *= (6 * len(x)) diff --git a/lib/mpl_toolkits/tests/test_mplot3d.py b/lib/mpl_toolkits/tests/test_mplot3d.py index fcc225053632..37532335e38d 100644 --- a/lib/mpl_toolkits/tests/test_mplot3d.py +++ b/lib/mpl_toolkits/tests/test_mplot3d.py @@ -36,6 +36,18 @@ def test_bar3d(): ax.bar(xs, ys, zs=z, zdir='y', align='edge', color=cs, alpha=0.8) +def test_bar3d_colors(): + fig = plt.figure() + ax = fig.add_subplot(111, projection='3d') + for c in ['red', 'green', 'blue', 'yellow']: + xs = np.arange(len(c)) + ys = np.zeros_like(xs) + zs = np.zeros_like(ys) + # Color names with same length as xs/ys/zs should not be split into + # individual letters. + ax.bar3d(xs, ys, zs, 1, 1, 1, color=c) + + @mpl3d_image_comparison(['bar3d_shaded.png']) def test_bar3d_shaded(): x = np.arange(4)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: