@@ -75,6 +75,7 @@ def set_3d_properties(self, z=0, zdir='z'):
75
75
x , y = self .get_position ()
76
76
self ._position3d = np .array ((x , y , z ))
77
77
self ._dir_vec = get_dir_vector (zdir )
78
+ self .stale = True
78
79
79
80
def draw (self , renderer ):
80
81
proj = proj3d .proj_trans_points ([self ._position3d , \
@@ -89,12 +90,15 @@ def draw(self, renderer):
89
90
self .set_position ((proj [0 ][0 ], proj [1 ][0 ]))
90
91
self .set_rotation (norm_text_angle (angle ))
91
92
mtext .Text .draw (self , renderer )
93
+ self .stale = False
94
+
92
95
93
96
def text_2d_to_3d (obj , z = 0 , zdir = 'z' ):
94
97
"""Convert a Text to a Text3D object."""
95
98
obj .__class__ = Text3D
96
99
obj .set_3d_properties (z , zdir )
97
100
101
+
98
102
class Line3D (lines .Line2D ):
99
103
'''
100
104
3D line object.
@@ -119,12 +123,15 @@ def set_3d_properties(self, zs=0, zdir='z'):
119
123
except TypeError :
120
124
pass
121
125
self ._verts3d = juggle_axes (xs , ys , zs , zdir )
126
+ self .stale = True
122
127
123
128
def draw (self , renderer ):
124
129
xs3d , ys3d , zs3d = self ._verts3d
125
130
xs , ys , zs = proj3d .proj_transform (xs3d , ys3d , zs3d , renderer .M )
126
131
self .set_data (xs , ys )
127
132
lines .Line2D .draw (self , renderer )
133
+ self .stale = False
134
+
128
135
129
136
def line_2d_to_3d (line , zs = 0 , zdir = 'z' ):
130
137
'''
@@ -170,9 +177,10 @@ def __init__(self, segments, *args, **kwargs):
170
177
'''
171
178
LineCollection .__init__ (self , segments , * args , ** kwargs )
172
179
173
- def set_sort_zpos (self ,val ):
180
+ def set_sort_zpos (self , val ):
174
181
'''Set the position to use for z-sorting.'''
175
182
self ._sort_zpos = val
183
+ self .stale = True
176
184
177
185
def set_segments (self , segments ):
178
186
'''
@@ -202,12 +210,14 @@ def draw(self, renderer, project=False):
202
210
self .do_3d_projection (renderer )
203
211
LineCollection .draw (self , renderer )
204
212
213
+
205
214
def line_collection_2d_to_3d (col , zs = 0 , zdir = 'z' ):
206
215
"""Convert a LineCollection to a Line3DCollection object."""
207
216
segments3d = paths_to_3d_segments (col .get_paths (), zs , zdir )
208
217
col .__class__ = Line3DCollection
209
218
col .set_segments (segments3d )
210
219
220
+
211
221
class Patch3D (Patch ):
212
222
'''
213
223
3D patch object.
@@ -322,10 +332,10 @@ def __init__(self, *args, **kwargs):
322
332
PatchCollection .__init__ (self , * args , ** kwargs )
323
333
self .set_3d_properties (zs , zdir )
324
334
325
-
326
- def set_sort_zpos (self ,val ):
335
+ def set_sort_zpos (self , val ):
327
336
'''Set the position to use for z-sorting.'''
328
337
self ._sort_zpos = val
338
+ self .stale = True
329
339
330
340
def set_3d_properties (self , zs , zdir ):
331
341
# Force the collection to initialize the face and edgecolors
@@ -340,6 +350,7 @@ def set_3d_properties(self, zs, zdir):
340
350
self ._offsets3d = juggle_axes (xs , ys , np .atleast_1d (zs ), zdir )
341
351
self ._facecolor3d = self .get_facecolor ()
342
352
self ._edgecolor3d = self .get_edgecolor ()
353
+ self .stale = True
343
354
344
355
def do_3d_projection (self , renderer ):
345
356
xs , ys , zs = self ._offsets3d
@@ -356,9 +367,9 @@ def do_3d_projection(self, renderer):
356
367
self .set_edgecolors (ecs )
357
368
PatchCollection .set_offsets (self , list (zip (vxs , vys )))
358
369
359
- if vzs .size > 0 :
370
+ if vzs .size > 0 :
360
371
return min (vzs )
361
- else :
372
+ else :
362
373
return np .nan
363
374
364
375
@@ -392,6 +403,7 @@ def __init__(self, *args, **kwargs):
392
403
def set_sort_zpos (self , val ):
393
404
'''Set the position to use for z-sorting.'''
394
405
self ._sort_zpos = val
406
+ self .stale = True
395
407
396
408
def set_3d_properties (self , zs , zdir ):
397
409
# Force the collection to initialize the face and edgecolors
@@ -406,6 +418,7 @@ def set_3d_properties(self, zs, zdir):
406
418
self ._offsets3d = juggle_axes (xs , ys , np .atleast_1d (zs ), zdir )
407
419
self ._facecolor3d = self .get_facecolor ()
408
420
self ._edgecolor3d = self .get_edgecolor ()
421
+ self .stale = True
409
422
410
423
def do_3d_projection (self , renderer ):
411
424
xs , ys , zs = self ._offsets3d
@@ -453,6 +466,7 @@ def patch_collection_2d_to_3d(col, zs=0, zdir='z', depthshade=True):
453
466
col ._depthshade = depthshade
454
467
col .set_3d_properties (zs , zdir )
455
468
469
+
456
470
class Poly3DCollection (PolyCollection ):
457
471
'''
458
472
A collection of 3D polygons.
@@ -502,6 +516,7 @@ def set_zsort(self, zsort):
502
516
self ._zsort = zsort
503
517
self ._sort_zpos = None
504
518
self ._zsortfunc = zsortfunc
519
+ self .stale = True
505
520
506
521
def get_vector (self , segments3d ):
507
522
"""Optimize points for projection"""
@@ -540,10 +555,12 @@ def set_3d_properties(self):
540
555
self ._facecolors3d = PolyCollection .get_facecolors (self )
541
556
self ._edgecolors3d = PolyCollection .get_edgecolors (self )
542
557
self ._alpha3d = PolyCollection .get_alpha (self )
558
+ self .stale = True
543
559
544
560
def set_sort_zpos (self ,val ):
545
561
'''Set the position to use for z-sorting.'''
546
562
self ._sort_zpos = val
563
+ self .stale = True
547
564
548
565
def do_3d_projection (self , renderer ):
549
566
'''
@@ -631,6 +648,7 @@ def set_alpha(self, alpha):
631
648
self ._edgecolors3d , self ._alpha )
632
649
except (AttributeError , TypeError , IndexError ):
633
650
pass
651
+ self .stale = True
634
652
635
653
def get_facecolors (self ):
636
654
return self ._facecolors2d
@@ -643,6 +661,7 @@ def get_edgecolors(self):
643
661
def draw (self , renderer ):
644
662
return Collection .draw (self , renderer )
645
663
664
+
646
665
def poly_collection_2d_to_3d (col , zs = 0 , zdir = 'z' ):
647
666
"""Convert a PolyCollection to a Poly3DCollection object."""
648
667
segments_3d = paths_to_3d_segments (col .get_paths (), zs , zdir )
0 commit comments