@@ -75,6 +75,7 @@ def set_3d_properties(self, z=0, zdir='z'):
7575 x , y = self .get_position ()
7676 self ._position3d = np .array ((x , y , z ))
7777 self ._dir_vec = get_dir_vector (zdir )
78+ self .stale = True
7879
7980 def draw (self , renderer ):
8081 proj = proj3d .proj_trans_points ([self ._position3d , \
@@ -89,12 +90,15 @@ def draw(self, renderer):
8990 self .set_position ((proj [0 ][0 ], proj [1 ][0 ]))
9091 self .set_rotation (norm_text_angle (angle ))
9192 mtext .Text .draw (self , renderer )
93+ self .stale = False
94+
9295
9396def text_2d_to_3d (obj , z = 0 , zdir = 'z' ):
9497 """Convert a Text to a Text3D object."""
9598 obj .__class__ = Text3D
9699 obj .set_3d_properties (z , zdir )
97100
101+
98102class Line3D (lines .Line2D ):
99103 '''
100104 3D line object.
@@ -119,12 +123,15 @@ def set_3d_properties(self, zs=0, zdir='z'):
119123 except TypeError :
120124 pass
121125 self ._verts3d = juggle_axes (xs , ys , zs , zdir )
126+ self .stale = True
122127
123128 def draw (self , renderer ):
124129 xs3d , ys3d , zs3d = self ._verts3d
125130 xs , ys , zs = proj3d .proj_transform (xs3d , ys3d , zs3d , renderer .M )
126131 self .set_data (xs , ys )
127132 lines .Line2D .draw (self , renderer )
133+ self .stale = False
134+
128135
129136def line_2d_to_3d (line , zs = 0 , zdir = 'z' ):
130137 '''
@@ -170,9 +177,10 @@ def __init__(self, segments, *args, **kwargs):
170177 '''
171178 LineCollection .__init__ (self , segments , * args , ** kwargs )
172179
173- def set_sort_zpos (self ,val ):
180+ def set_sort_zpos (self , val ):
174181 '''Set the position to use for z-sorting.'''
175182 self ._sort_zpos = val
183+ self .stale = True
176184
177185 def set_segments (self , segments ):
178186 '''
@@ -202,12 +210,14 @@ def draw(self, renderer, project=False):
202210 self .do_3d_projection (renderer )
203211 LineCollection .draw (self , renderer )
204212
213+
205214def line_collection_2d_to_3d (col , zs = 0 , zdir = 'z' ):
206215 """Convert a LineCollection to a Line3DCollection object."""
207216 segments3d = paths_to_3d_segments (col .get_paths (), zs , zdir )
208217 col .__class__ = Line3DCollection
209218 col .set_segments (segments3d )
210219
220+
211221class Patch3D (Patch ):
212222 '''
213223 3D patch object.
@@ -322,10 +332,10 @@ def __init__(self, *args, **kwargs):
322332 PatchCollection .__init__ (self , * args , ** kwargs )
323333 self .set_3d_properties (zs , zdir )
324334
325-
326- def set_sort_zpos (self ,val ):
335+ def set_sort_zpos (self , val ):
327336 '''Set the position to use for z-sorting.'''
328337 self ._sort_zpos = val
338+ self .stale = True
329339
330340 def set_3d_properties (self , zs , zdir ):
331341 # Force the collection to initialize the face and edgecolors
@@ -340,6 +350,7 @@ def set_3d_properties(self, zs, zdir):
340350 self ._offsets3d = juggle_axes (xs , ys , np .atleast_1d (zs ), zdir )
341351 self ._facecolor3d = self .get_facecolor ()
342352 self ._edgecolor3d = self .get_edgecolor ()
353+ self .stale = True
343354
344355 def do_3d_projection (self , renderer ):
345356 xs , ys , zs = self ._offsets3d
@@ -356,9 +367,9 @@ def do_3d_projection(self, renderer):
356367 self .set_edgecolors (ecs )
357368 PatchCollection .set_offsets (self , list (zip (vxs , vys )))
358369
359- if vzs .size > 0 :
370+ if vzs .size > 0 :
360371 return min (vzs )
361- else :
372+ else :
362373 return np .nan
363374
364375
@@ -392,6 +403,7 @@ def __init__(self, *args, **kwargs):
392403 def set_sort_zpos (self , val ):
393404 '''Set the position to use for z-sorting.'''
394405 self ._sort_zpos = val
406+ self .stale = True
395407
396408 def set_3d_properties (self , zs , zdir ):
397409 # Force the collection to initialize the face and edgecolors
@@ -406,6 +418,7 @@ def set_3d_properties(self, zs, zdir):
406418 self ._offsets3d = juggle_axes (xs , ys , np .atleast_1d (zs ), zdir )
407419 self ._facecolor3d = self .get_facecolor ()
408420 self ._edgecolor3d = self .get_edgecolor ()
421+ self .stale = True
409422
410423 def do_3d_projection (self , renderer ):
411424 xs , ys , zs = self ._offsets3d
@@ -453,6 +466,7 @@ def patch_collection_2d_to_3d(col, zs=0, zdir='z', depthshade=True):
453466 col ._depthshade = depthshade
454467 col .set_3d_properties (zs , zdir )
455468
469+
456470class Poly3DCollection (PolyCollection ):
457471 '''
458472 A collection of 3D polygons.
@@ -502,6 +516,7 @@ def set_zsort(self, zsort):
502516 self ._zsort = zsort
503517 self ._sort_zpos = None
504518 self ._zsortfunc = zsortfunc
519+ self .stale = True
505520
506521 def get_vector (self , segments3d ):
507522 """Optimize points for projection"""
@@ -540,10 +555,12 @@ def set_3d_properties(self):
540555 self ._facecolors3d = PolyCollection .get_facecolors (self )
541556 self ._edgecolors3d = PolyCollection .get_edgecolors (self )
542557 self ._alpha3d = PolyCollection .get_alpha (self )
558+ self .stale = True
543559
544560 def set_sort_zpos (self ,val ):
545561 '''Set the position to use for z-sorting.'''
546562 self ._sort_zpos = val
563+ self .stale = True
547564
548565 def do_3d_projection (self , renderer ):
549566 '''
@@ -631,6 +648,7 @@ def set_alpha(self, alpha):
631648 self ._edgecolors3d , self ._alpha )
632649 except (AttributeError , TypeError , IndexError ):
633650 pass
651+ self .stale = True
634652
635653 def get_facecolors (self ):
636654 return self ._facecolors2d
@@ -643,6 +661,7 @@ def get_edgecolors(self):
643661 def draw (self , renderer ):
644662 return Collection .draw (self , renderer )
645663
664+
646665def poly_collection_2d_to_3d (col , zs = 0 , zdir = 'z' ):
647666 """Convert a PolyCollection to a Poly3DCollection object."""
648667 segments_3d = paths_to_3d_segments (col .get_paths (), zs , zdir )
0 commit comments