From a3a652f3394d7d25967394f0ee334c3394e629ec Mon Sep 17 00:00:00 2001 From: Umar Javed Date: Wed, 4 Dec 2019 03:57:46 +0500 Subject: [PATCH 1/2] Fix bar3d bug with matching color string and array x lengths --- lib/mpl_toolkits/mplot3d/axes3d.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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)) From 680e839635b950323112c421a349bec04afc29e8 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 8 Jun 2020 19:46:46 -0400 Subject: [PATCH 2/2] Add a simple smoke test for bar3d colors. --- lib/mpl_toolkits/tests/test_mplot3d.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy