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

Skip to content

Commit 9a164c7

Browse files
committed
Merge pull request #2732 from mdboom/fix-patch3dcollection
AttributeError: 'Patch3DCollection' object has no attribute 'set_sizes'
2 parents 9e0be95 + 28331bf commit 9a164c7

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

lib/matplotlib/backends/backend_macosx.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
7676
master_transform, paths, all_transforms):
7777
path_ids.append((path, transform))
7878
master_transform = master_transform.get_matrix()
79-
all_transforms = [t.get_matrix() for t in all_transforms]
8079
offsetTrans = offsetTrans.get_matrix()
8180
gc.draw_path_collection(master_transform, path_ids, all_transforms,
8281
offsets, offsetTrans, facecolors, edgecolors,

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from matplotlib import lines, text as mtext, path as mpath, colors as mcolors
1717
from matplotlib.collections import Collection, LineCollection, \
18-
PolyCollection, PatchCollection
18+
PolyCollection, PatchCollection, PathCollection
1919
from matplotlib.cm import ScalarMappable
2020
from matplotlib.patches import Patch
2121
from matplotlib.colors import Normalize
@@ -294,7 +294,7 @@ def pathpatch_2d_to_3d(pathpatch, z=0, zdir='z'):
294294
pathpatch.__class__ = PathPatch3D
295295
pathpatch.set_3d_properties(mpath, z, zdir)
296296

297-
class Patch3DCollection(PatchCollection):
297+
class Collection3D(object):
298298
'''
299299
A collection of 3D patches.
300300
'''
@@ -343,7 +343,7 @@ def do_3d_projection(self, renderer):
343343
self._alpha = None
344344
self.set_facecolors(zalpha(self._facecolor3d, vzs))
345345
self.set_edgecolors(zalpha(self._edgecolor3d, vzs))
346-
PatchCollection.set_offsets(self, list(zip(vxs, vys)))
346+
super(self.__class__, self).set_offsets(list(zip(vxs, vys)))
347347

348348
if vzs.size > 0 :
349349
return min(vzs)
@@ -353,14 +353,26 @@ def do_3d_projection(self, renderer):
353353
def draw(self, renderer):
354354
self._old_draw(renderer)
355355

356+
357+
class Patch3DCollection(Collection3D, PatchCollection):
358+
pass
359+
360+
361+
class Path3DCollection(Collection3D, PathCollection):
362+
pass
363+
364+
356365
def patch_collection_2d_to_3d(col, zs=0, zdir='z'):
357366
"""Convert a PatchCollection to a Patch3DCollection object."""
358367

359368
# The tricky part here is that there are several classes that are
360369
# derived from PatchCollection. We need to use the right draw method.
361370
col._old_draw = col.draw
362371

363-
col.__class__ = Patch3DCollection
372+
if isinstance(col, PathCollection):
373+
col.__class__ = Path3DCollection
374+
elif isinstance(col, PatchCollection):
375+
col.__class__ = Patch3DCollection
364376
col.set_3d_properties(zs, zdir)
365377

366378
class Poly3DCollection(PolyCollection):

0 commit comments

Comments
 (0)