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

Skip to content

Commit 1e73931

Browse files
committed
Forward keyword arguments onto Poly3DCollection
Also test that the result is indexable
1 parent 3c37cfb commit 1e73931

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,7 +2745,7 @@ def calc_arrow(uvw, angle=15):
27452745

27462746
quiver3D = quiver
27472747

2748-
def voxels(self, filled, color=None):
2748+
def voxels(self, filled, color=None, **kwargs):
27492749
"""
27502750
Plot a set of filled voxels
27512751
@@ -2766,6 +2766,9 @@ def voxels(self, filled, color=None):
27662766
indicating what color to draw the faces of the voxels. If None,
27672767
plot all voxels in the same color, the next in the color sequence.
27682768
2769+
Any additional keyword arguments are passed onto
2770+
:func:`~mpl_toolkits.mplot3d.art3d.Poly3DCollection`
2771+
27692772
Returns
27702773
-------
27712774
faces : dict
@@ -2863,7 +2866,10 @@ def permutation_matrices(n):
28632866
# iterate over the faces, and generate a Poly3DCollection for each voxel
28642867
polygons = {}
28652868
for coord, faces in voxel_faces.items():
2866-
poly = art3d.Poly3DCollection(faces, facecolors=color[coord])
2869+
poly = art3d.Poly3DCollection(faces,
2870+
facecolors=color[coord],
2871+
**kwargs
2872+
)
28672873
self.add_collection3d(poly)
28682874
polygons[coord] = poly
28692875

63.7 KB
Loading

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,22 @@ def test_simple(self):
582582
voxels = (x == y) | (y == z)
583583
ax.voxels(voxels)
584584

585+
@image_comparison(
586+
baseline_images=['voxels-edge-style'],
587+
extensions=['png'],
588+
remove_text=True,
589+
style='default'
590+
)
591+
def test_edge_style(self):
592+
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
593+
594+
x, y, z = np.indices((5, 5, 4))
595+
voxels = ((x - 2)**2 + (y - 2)**2 + (z-1.5)**2) < 2.2**2
596+
v = ax.voxels(voxels, linewidths=3, edgecolor='C1')
597+
598+
# change the edge color of one voxel
599+
v[max(v.keys())].set_edgecolor('C2')
600+
585601

586602
@image_comparison(
587603
baseline_images=['voxels-named-colors'],

0 commit comments

Comments
 (0)