Skip to content

Commit 3417360

Browse files
committed
Remove unnecessary facecolor cache in Patch3D.
It simply copies the value from the 2D version to `self._facecolor3d`, and then later to `self._facecolor2d`, but never does anything to require these additional copies. Fixes #18815.
1 parent a2b924c commit 3417360

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,23 +344,17 @@ def set_3d_properties(self, verts, zs=0, zdir='z'):
344344
zs = np.broadcast_to(zs, len(verts))
345345
self._segment3d = [juggle_axes(x, y, z, zdir)
346346
for ((x, y), z) in zip(verts, zs)]
347-
self._facecolor3d = Patch.get_facecolor(self)
348347

349348
def get_path(self):
350349
return self._path2d
351350

352-
def get_facecolor(self):
353-
return self._facecolor2d
354-
355351
@_api.delete_parameter('3.4', 'renderer')
356352
def do_3d_projection(self, renderer=None):
357353
s = self._segment3d
358354
xs, ys, zs = zip(*s)
359355
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs,
360356
self.axes.M)
361357
self._path2d = mpath.Path(np.column_stack([vxs, vys]))
362-
# FIXME: coloring
363-
self._facecolor2d = self._facecolor3d
364358
return min(vzs)
365359

366360

@@ -385,8 +379,6 @@ def do_3d_projection(self, renderer=None):
385379
vxs, vys, vzs, vis = proj3d.proj_transform_clip(xs, ys, zs,
386380
self.axes.M)
387381
self._path2d = mpath.Path(np.column_stack([vxs, vys]), self._code3d)
388-
# FIXME: coloring
389-
self._facecolor2d = self._facecolor3d
390382
return min(vzs)
391383

392384

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,19 @@ def test_quiver3d_masked():
582582
ax.quiver(x, y, z, u, v, w, length=0.1, pivot='tip', normalize=True)
583583

584584

585+
def test_patch_modification():
586+
fig = plt.figure()
587+
ax = fig.add_subplot(projection="3d")
588+
circle = Circle((0, 0))
589+
ax.add_patch(circle)
590+
art3d.patch_2d_to_3d(circle)
591+
circle.set_facecolor((1.0, 0.0, 0.0, 1))
592+
593+
assert mcolors.same_color(circle.get_facecolor(), (1, 0, 0, 1))
594+
fig.canvas.draw()
595+
assert mcolors.same_color(circle.get_facecolor(), (1, 0, 0, 1))
596+
597+
585598
@check_figures_equal(extensions=['png'])
586599
def test_patch_collection_modification(fig_test, fig_ref):
587600
# Test that modifying Patch3DCollection properties after creation works.

0 commit comments

Comments
 (0)