@@ -293,8 +293,23 @@ class Patch3DCollection(PatchCollection):
293
293
'''
294
294
295
295
def __init__ (self , * args , ** kwargs ):
296
+ """
297
+ Create a collection of flat 3D patches with its normal vector
298
+ pointed in *zdir* direction, and located at *zs* on the *zdir*
299
+ axis. 'zs' can be a scalar or an array-like of the same length as
300
+ the number of patches in the collection.
301
+
302
+ Constructor arguments are the same as for
303
+ :class:`~matplotlib.collections.PatchCollection`. In addition,
304
+ keywords *zs=0* and *zdir='z'* are available.
305
+
306
+ """
307
+ zs = kwargs .pop ('zs' , 0 )
308
+ zdir = kwargs .pop ('zdir' , 'z' )
296
309
PatchCollection .__init__ (self , * args , ** kwargs )
297
310
self ._old_draw = lambda x : PatchCollection .draw (self , x )
311
+ self .set_3d_properties (zs , zdir )
312
+
298
313
299
314
def set_sort_zpos (self ,val ):
300
315
'''Set the position to use for z-sorting.'''
@@ -306,11 +321,11 @@ def set_3d_properties(self, zs, zdir):
306
321
self .update_scalarmappable ()
307
322
offsets = self .get_offsets ()
308
323
if len (offsets ) > 0 :
309
- xs , ys = zip (* self . get_offsets () )
324
+ xs , ys = zip (* offsets )
310
325
else :
311
- xs = [0 ] * len ( zs )
312
- ys = [0 ] * len ( zs )
313
- self ._offsets3d = juggle_axes (xs , ys , zs , zdir )
326
+ xs = []
327
+ ys = []
328
+ self ._offsets3d = juggle_axes (xs , ys , np . atleast_1d ( zs ) , zdir )
314
329
self ._facecolor3d = self .get_facecolor ()
315
330
self ._edgecolor3d = self .get_edgecolor ()
316
331
0 commit comments