Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5314244

Browse files
committed
MAINT: Vectorize the entire computation of the bar3d polygons
1 parent 7d09535 commit 5314244

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,11 +2478,14 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None,
24782478
),
24792479
])
24802480

2481-
polys = []
2482-
for xi, yi, zi, dxi, dyi, dzi in zip(x, y, z, dx, dy, dz):
2483-
corner = np.array([xi, yi, zi])
2484-
scale = np.array([dxi, dyi, dzi])
2485-
polys.extend(corner + scale * cuboid)
2481+
polys = np.empty(x.shape + cuboid.shape)
2482+
2483+
# handle each coordinate separately
2484+
for i, p, dp in [(0, x, dx), (1, y, dy), (2, z, dz)]:
2485+
polys[..., i] = p + dp * cuboid[..., i]
2486+
2487+
# collapse the first two axes
2488+
polys = polys.reshape((-1,) + polys.shape[2:])
24862489

24872490
facecolors = []
24882491
if color is None:

0 commit comments

Comments
 (0)