Skip to content

Commit 5157797

Browse files
authored
Merge pull request #15826 from UmarJ/bugfix-for-issue-15815
Fix bar3d bug with matching color string and array x lengths
2 parents 43a4c2b + 680e839 commit 5157797

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2507,13 +2507,15 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None,
25072507
if color is None:
25082508
color = [self._get_patches_for_fill.get_next_color()]
25092509

2510+
color = list(mcolors.to_rgba_array(color))
2511+
25102512
if len(color) == len(x):
25112513
# bar colors specified, need to expand to number of faces
25122514
for c in color:
25132515
facecolors.extend([c] * 6)
25142516
else:
25152517
# a single color specified, or face colors specified explicitly
2516-
facecolors = list(mcolors.to_rgba_array(color))
2518+
facecolors = color
25172519
if len(facecolors) < len(x):
25182520
facecolors *= (6 * len(x))
25192521

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ def test_bar3d():
3636
ax.bar(xs, ys, zs=z, zdir='y', align='edge', color=cs, alpha=0.8)
3737

3838

39+
def test_bar3d_colors():
40+
fig = plt.figure()
41+
ax = fig.add_subplot(111, projection='3d')
42+
for c in ['red', 'green', 'blue', 'yellow']:
43+
xs = np.arange(len(c))
44+
ys = np.zeros_like(xs)
45+
zs = np.zeros_like(ys)
46+
# Color names with same length as xs/ys/zs should not be split into
47+
# individual letters.
48+
ax.bar3d(xs, ys, zs, 1, 1, 1, color=c)
49+
50+
3951
@mpl3d_image_comparison(['bar3d_shaded.png'])
4052
def test_bar3d_shaded():
4153
x = np.arange(4)

0 commit comments

Comments
 (0)
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