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

Skip to content

Commit dcc48e4

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

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,11 +2478,12 @@ 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+
for i, p, dp in [(0, x, dx), (1, y, dy), (2, z, dz)]:
2483+
polys[..., i] = p + dp * cuboid
2484+
2485+
# collapse the first two axes
2486+
polys = polys.reshape((-1,) + polys.shape[2:])
24862487

24872488
facecolors = []
24882489
if color is None:

0 commit comments

Comments
 (0)