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

Skip to content

Commit 7d09535

Browse files
committed
MAINT: Pre-compute the cuboid array
1 parent 351f460 commit 7d09535

File tree

1 file changed

+47
-44
lines changed

1 file changed

+47
-44
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,54 +2432,57 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None,
24322432
minz = np.min(z)
24332433
maxz = np.max(z + dz)
24342434

2435+
# shape (6, 4, 3)
2436+
cuboid = np.array([
2437+
# -z
2438+
(
2439+
(0, 0, 0),
2440+
(1, 0, 0),
2441+
(1, 1, 0),
2442+
(0, 1, 0)
2443+
),
2444+
# +z
2445+
(
2446+
(0, 0, 1),
2447+
(1, 0, 1),
2448+
(1, 1, 1),
2449+
(0, 1, 1)
2450+
),
2451+
# -y
2452+
(
2453+
(0, 0, 0),
2454+
(1, 0, 0),
2455+
(1, 0, 1),
2456+
(0, 0, 1)
2457+
),
2458+
# +y
2459+
(
2460+
(0, 1, 0),
2461+
(1, 1, 0),
2462+
(1, 1, 1),
2463+
(0, 1, 1)
2464+
),
2465+
# -x
2466+
(
2467+
(0, 0, 0),
2468+
(0, 1, 0),
2469+
(0, 1, 1),
2470+
(0, 0, 1)
2471+
),
2472+
# +x
2473+
(
2474+
(1, 0, 0),
2475+
(1, 1, 0),
2476+
(1, 1, 1),
2477+
(1, 0, 1)
2478+
),
2479+
])
2480+
24352481
polys = []
24362482
for xi, yi, zi, dxi, dyi, dzi in zip(x, y, z, dx, dy, dz):
24372483
corner = np.array([xi, yi, zi])
24382484
scale = np.array([dxi, dyi, dzi])
2439-
polys.extend(corner + scale * [
2440-
# -z
2441-
(
2442-
(0, 0, 0),
2443-
(1, 0, 0),
2444-
(1, 1, 0),
2445-
(0, 1, 0)
2446-
),
2447-
# +z
2448-
(
2449-
(0, 0, 1),
2450-
(1, 0, 1),
2451-
(1, 1, 1),
2452-
(0, 1, 1)
2453-
),
2454-
# -y
2455-
(
2456-
(0, 0, 0),
2457-
(1, 0, 0),
2458-
(1, 0, 1),
2459-
(0, 0, 1)
2460-
),
2461-
# +y
2462-
(
2463-
(0, 1, 0),
2464-
(1, 1, 0),
2465-
(1, 1, 1),
2466-
(0, 1, 1)
2467-
),
2468-
# -x
2469-
(
2470-
(0, 0, 0),
2471-
(0, 1, 0),
2472-
(0, 1, 1),
2473-
(0, 0, 1)
2474-
),
2475-
# +x
2476-
(
2477-
(1, 0, 0),
2478-
(1, 1, 0),
2479-
(1, 1, 1),
2480-
(1, 0, 1)
2481-
),
2482-
])
2485+
polys.extend(corner + scale * cuboid)
24832486

24842487
facecolors = []
24852488
if color is None:

0 commit comments

Comments
 (0)