15
15
16
16
from matplotlib import lines , text as mtext , path as mpath , colors as mcolors
17
17
from matplotlib .collections import Collection , LineCollection , \
18
- PolyCollection , PatchCollection
18
+ PolyCollection , PatchCollection , PathCollection
19
19
from matplotlib .cm import ScalarMappable
20
20
from matplotlib .patches import Patch
21
21
from matplotlib .colors import Normalize
@@ -294,7 +294,7 @@ def pathpatch_2d_to_3d(pathpatch, z=0, zdir='z'):
294
294
pathpatch .__class__ = PathPatch3D
295
295
pathpatch .set_3d_properties (mpath , z , zdir )
296
296
297
- class Patch3DCollection ( PatchCollection ):
297
+ class Collection3D ( object ):
298
298
'''
299
299
A collection of 3D patches.
300
300
'''
@@ -343,7 +343,7 @@ def do_3d_projection(self, renderer):
343
343
self ._alpha = None
344
344
self .set_facecolors (zalpha (self ._facecolor3d , vzs ))
345
345
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 )))
347
347
348
348
if vzs .size > 0 :
349
349
return min (vzs )
@@ -353,14 +353,26 @@ def do_3d_projection(self, renderer):
353
353
def draw (self , renderer ):
354
354
self ._old_draw (renderer )
355
355
356
+
357
+ class Patch3DCollection (Collection3D , PatchCollection ):
358
+ pass
359
+
360
+
361
+ class Path3DCollection (Collection3D , PathCollection ):
362
+ pass
363
+
364
+
356
365
def patch_collection_2d_to_3d (col , zs = 0 , zdir = 'z' ):
357
366
"""Convert a PatchCollection to a Patch3DCollection object."""
358
367
359
368
# The tricky part here is that there are several classes that are
360
369
# derived from PatchCollection. We need to use the right draw method.
361
370
col ._old_draw = col .draw
362
371
363
- col .__class__ = Patch3DCollection
372
+ if isinstance (col , PathCollection ):
373
+ col .__class__ = Path3DCollection
374
+ elif isinstance (col , PatchCollection ):
375
+ col .__class__ = Patch3DCollection
364
376
col .set_3d_properties (zs , zdir )
365
377
366
378
class Poly3DCollection (PolyCollection ):
0 commit comments