(box, proc, fig, ax: Axes)
| 1295 | owners = sim.structure.get_chunk_owners() |
| 1296 | |
| 1297 | def plot_box(box, proc, fig, ax: Axes): |
| 1298 | if sim.structure.gv.dim == 2: |
| 1299 | low = Vector3(box.low.x, box.low.y, box.low.z) |
| 1300 | high = Vector3(box.high.x, box.high.y, box.high.z) |
| 1301 | points = [low, high] |
| 1302 | |
| 1303 | x_len = Vector3(high.x) - Vector3(low.x) |
| 1304 | y_len = Vector3(y=high.y) - Vector3(y=low.y) |
| 1305 | xy_len = Vector3(high.x, high.y) - Vector3(low.x, low.y) |
| 1306 | |
| 1307 | points += [low + x_len] |
| 1308 | points += [low + y_len] |
| 1309 | points += [low + xy_len] |
| 1310 | points += [high - x_len] |
| 1311 | points += [high - y_len] |
| 1312 | points += [high - xy_len] |
| 1313 | points = np.array([np.array(v) for v in points]) |
| 1314 | |
| 1315 | edges = [ |
| 1316 | [points[0], points[2], points[4], points[3]], |
| 1317 | [points[1], points[5], points[7], points[6]], |
| 1318 | [points[0], points[3], points[5], points[7]], |
| 1319 | [points[1], points[4], points[2], points[6]], |
| 1320 | [points[3], points[4], points[1], points[5]], |
| 1321 | [points[0], points[7], points[6], points[2]], |
| 1322 | ] |
| 1323 | |
| 1324 | faces = Poly3DCollection(edges, linewidths=1, edgecolors="k") |
| 1325 | color_with_alpha = matplotlib.colors.to_rgba(chunk_colors[proc], alpha=0.2) |
| 1326 | faces.set_facecolor(color_with_alpha) |
| 1327 | ax.add_collection3d(faces) |
| 1328 | |
| 1329 | # Plot the points themselves to force the scaling of the axes |
| 1330 | ax.scatter(points[:, 0], points[:, 1], points[:, 2], s=0) |
| 1331 | else: |
| 1332 | low = Vector3(box.low.x, box.low.y) |
| 1333 | high = Vector3(box.high.x, box.high.y) |
| 1334 | points = [low, high] |
| 1335 | |
| 1336 | x_len = Vector3(high.x) - Vector3(low.x) |
| 1337 | y_len = Vector3(y=high.y) - Vector3(y=low.y) |
| 1338 | |
| 1339 | points += [low + x_len] |
| 1340 | points += [low + y_len] |
| 1341 | points = np.array([np.array(v)[:-1] for v in points]) |
| 1342 | |
| 1343 | edges = [[points[0], points[2], points[1], points[3]]] |
| 1344 | |
| 1345 | faces = PolyCollection(edges, linewidths=1, edgecolors="k") |
| 1346 | color_with_alpha = matplotlib.colors.to_rgba(chunk_colors[proc]) |
| 1347 | faces.set_facecolor(color_with_alpha) |
| 1348 | ax.add_collection(faces) |
| 1349 | |
| 1350 | # Plot the points themselves to force the scaling of the axes |
| 1351 | ax.scatter(points[:, 0], points[:, 1], s=0) |
| 1352 | |
| 1353 | if mp.am_master(): |
| 1354 | fig = plt.figure() |
no test coverage detected