1515
1616from matplotlib import lines , text as mtext , path as mpath , colors as mcolors
1717from matplotlib .collections import Collection , LineCollection , \
18- PolyCollection , PatchCollection
18+ PolyCollection , PatchCollection , PathCollection
1919from matplotlib .cm import ScalarMappable
2020from matplotlib .patches import Patch
2121from 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+
356365def 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
366378class Poly3DCollection (PolyCollection ):
0 commit comments