20
20
from . import proj3d
21
21
22
22
23
- def norm_angle (a ):
23
+ def _norm_angle (a ):
24
24
"""Return the given angle normalized to -180 < *a* <= 180 degrees."""
25
25
a = (a + 360 ) % 360
26
26
if a > 180 :
27
27
a = a - 360
28
28
return a
29
29
30
30
31
- def norm_text_angle (a ):
31
+ @cbook .deprecated ("3.1" )
32
+ def norm_angle (a ):
33
+ """Return the given angle normalized to -180 < *a* <= 180 degrees."""
34
+ return _norm_angle (a )
35
+
36
+
37
+ def _norm_text_angle (a ):
32
38
"""Return the given angle normalized to -90 < *a* <= 90 degrees."""
33
39
a = (a + 180 ) % 180
34
40
if a > 90 :
35
41
a = a - 180
36
42
return a
37
43
38
44
45
+ @cbook .deprecated ("3.1" )
46
+ def norm_text_angle (a ):
47
+ """Return the given angle normalized to -90 < *a* <= 90 degrees."""
48
+ return _norm_text_angle (a )
49
+
50
+
39
51
def get_dir_vector (zdir ):
40
52
"""
41
53
Return a direction vector.
@@ -109,7 +121,7 @@ def draw(self, renderer):
109
121
dy = proj [1 ][1 ] - proj [1 ][0 ]
110
122
angle = math .degrees (math .atan2 (dy , dx ))
111
123
self .set_position ((proj [0 ][0 ], proj [1 ][0 ]))
112
- self .set_rotation (norm_text_angle (angle ))
124
+ self .set_rotation (_norm_text_angle (angle ))
113
125
mtext .Text .draw (self , renderer )
114
126
self .stale = False
115
127
@@ -200,7 +212,7 @@ def line_2d_to_3d(line, zs=0, zdir='z'):
200
212
line .set_3d_properties (zs , zdir )
201
213
202
214
203
- def path_to_3d_segment (path , zs = 0 , zdir = 'z' ):
215
+ def _path_to_3d_segment (path , zs = 0 , zdir = 'z' ):
204
216
"""Convert a path to a 3D segment."""
205
217
206
218
zs = np .broadcast_to (zs , len (path ))
@@ -210,16 +222,28 @@ def path_to_3d_segment(path, zs=0, zdir='z'):
210
222
return seg3d
211
223
212
224
213
- def paths_to_3d_segments (paths , zs = 0 , zdir = 'z' ):
225
+ @cbook .deprecated ("3.1" )
226
+ def path_to_3d_segment (path , zs = 0 , zdir = 'z' ):
227
+ """Convert a path to a 3D segment."""
228
+ return _path_to_3d_segment (path , zs = zs , zdir = zdir )
229
+
230
+
231
+ def _paths_to_3d_segments (paths , zs = 0 , zdir = 'z' ):
214
232
"""Convert paths from a collection object to 3D segments."""
215
233
216
234
zs = np .broadcast_to (zs , len (paths ))
217
- segs = [path_to_3d_segment (path , pathz , zdir )
235
+ segs = [_path_to_3d_segment (path , pathz , zdir )
218
236
for path , pathz in zip (paths , zs )]
219
237
return segs
220
238
221
239
222
- def path_to_3d_segment_with_codes (path , zs = 0 , zdir = 'z' ):
240
+ @cbook .deprecated ("3.1" )
241
+ def paths_to_3d_segments (paths , zs = 0 , zdir = 'z' ):
242
+ """Convert paths from a collection object to 3D segments."""
243
+ return _paths_to_3d_segments (paths , zs = zs , zdir = zdir )
244
+
245
+
246
+ def _path_to_3d_segment_with_codes (path , zs = 0 , zdir = 'z' ):
223
247
"""Convert a path to a 3D segment with path codes."""
224
248
225
249
zs = np .broadcast_to (zs , len (path ))
@@ -234,13 +258,19 @@ def path_to_3d_segment_with_codes(path, zs=0, zdir='z'):
234
258
return seg3d , list (codes )
235
259
236
260
237
- def paths_to_3d_segments_with_codes (paths , zs = 0 , zdir = 'z' ):
261
+ @cbook .deprecated ("3.1" )
262
+ def path_to_3d_segment_with_codes (path , zs = 0 , zdir = 'z' ):
263
+ """Convert a path to a 3D segment with path codes."""
264
+ return _path_to_3d_segment_with_codes (path , zs = zs , zdir = zdir )
265
+
266
+
267
+ def _paths_to_3d_segments_with_codes (paths , zs = 0 , zdir = 'z' ):
238
268
"""
239
269
Convert paths from a collection object to 3D segments with path codes.
240
270
"""
241
271
242
272
zs = np .broadcast_to (zs , len (paths ))
243
- segments_codes = [path_to_3d_segment_with_codes (path , pathz , zdir )
273
+ segments_codes = [_path_to_3d_segment_with_codes (path , pathz , zdir )
244
274
for path , pathz in zip (paths , zs )]
245
275
if segments_codes :
246
276
segments , codes = zip (* segments_codes )
@@ -249,6 +279,14 @@ def paths_to_3d_segments_with_codes(paths, zs=0, zdir='z'):
249
279
return list (segments ), list (codes )
250
280
251
281
282
+ @cbook .deprecated ("3.1" )
283
+ def paths_to_3d_segments_with_codes (paths , zs = 0 , zdir = 'z' ):
284
+ """
285
+ Convert paths from a collection object to 3D segments with path codes.
286
+ """
287
+ return _paths_to_3d_segments_with_codes (paths , zs = zs , zdir = zdir )
288
+
289
+
252
290
class Line3DCollection (LineCollection ):
253
291
"""
254
292
A collection of 3D lines.
@@ -291,7 +329,7 @@ def draw(self, renderer, project=False):
291
329
292
330
def line_collection_2d_to_3d (col , zs = 0 , zdir = 'z' ):
293
331
"""Convert a LineCollection to a Line3DCollection object."""
294
- segments3d = paths_to_3d_segments (col .get_paths (), zs , zdir )
332
+ segments3d = _paths_to_3d_segments (col .get_paths (), zs , zdir )
295
333
col .__class__ = Line3DCollection
296
334
col .set_segments (segments3d )
297
335
@@ -350,7 +388,7 @@ def do_3d_projection(self, renderer):
350
388
return min (vzs )
351
389
352
390
353
- def get_patch_verts (patch ):
391
+ def _get_patch_verts (patch ):
354
392
"""Return a list of vertices for the path of a patch."""
355
393
trans = patch .get_patch_transform ()
356
394
path = patch .get_path ()
@@ -361,9 +399,15 @@ def get_patch_verts(patch):
361
399
return []
362
400
363
401
402
+ @cbook .deprecated ("3.1" )
403
+ def get_patch_verts (patch ):
404
+ """Return a list of vertices for the path of a patch."""
405
+ return _get_patch_verts (patch )
406
+
407
+
364
408
def patch_2d_to_3d (patch , z = 0 , zdir = 'z' ):
365
409
"""Convert a Patch to a Patch3D object."""
366
- verts = get_patch_verts (patch )
410
+ verts = _get_patch_verts (patch )
367
411
patch .__class__ = Patch3D
368
412
patch .set_3d_properties (verts , z , zdir )
369
413
@@ -427,12 +471,12 @@ def do_3d_projection(self, renderer):
427
471
xs , ys , zs = self ._offsets3d
428
472
vxs , vys , vzs , vis = proj3d .proj_transform_clip (xs , ys , zs , renderer .M )
429
473
430
- fcs = (zalpha (self ._facecolor3d , vzs ) if self ._depthshade else
474
+ fcs = (_zalpha (self ._facecolor3d , vzs ) if self ._depthshade else
431
475
self ._facecolor3d )
432
476
fcs = mcolors .to_rgba_array (fcs , self ._alpha )
433
477
self .set_facecolors (fcs )
434
478
435
- ecs = (zalpha (self ._edgecolor3d , vzs ) if self ._depthshade else
479
+ ecs = (_zalpha (self ._edgecolor3d , vzs ) if self ._depthshade else
436
480
self ._edgecolor3d )
437
481
ecs = mcolors .to_rgba_array (ecs , self ._alpha )
438
482
self .set_edgecolors (ecs )
@@ -493,12 +537,12 @@ def do_3d_projection(self, renderer):
493
537
xs , ys , zs = self ._offsets3d
494
538
vxs , vys , vzs , vis = proj3d .proj_transform_clip (xs , ys , zs , renderer .M )
495
539
496
- fcs = (zalpha (self ._facecolor3d , vzs ) if self ._depthshade else
540
+ fcs = (_zalpha (self ._facecolor3d , vzs ) if self ._depthshade else
497
541
self ._facecolor3d )
498
542
fcs = mcolors .to_rgba_array (fcs , self ._alpha )
499
543
self .set_facecolors (fcs )
500
544
501
- ecs = (zalpha (self ._edgecolor3d , vzs ) if self ._depthshade else
545
+ ecs = (_zalpha (self ._edgecolor3d , vzs ) if self ._depthshade else
502
546
self ._edgecolor3d )
503
547
ecs = mcolors .to_rgba_array (ecs , self ._alpha )
504
548
self .set_edgecolors (ecs )
@@ -643,7 +687,7 @@ def do_3d_projection(self, renderer):
643
687
self .update_scalarmappable ()
644
688
self ._facecolors3d = self ._facecolors
645
689
646
- txs , tys , tzs = proj3d .proj_transform_vec (self ._vec , renderer .M )
690
+ txs , tys , tzs = proj3d ._proj_transform_vec (self ._vec , renderer .M )
647
691
xyzlist = [(txs [si :ei ], tys [si :ei ], tzs [si :ei ])
648
692
for si , ei in self ._segis ]
649
693
@@ -681,7 +725,7 @@ def do_3d_projection(self, renderer):
681
725
# Return zorder value
682
726
if self ._sort_zpos is not None :
683
727
zvec = np .array ([[0 ], [0 ], [self ._sort_zpos ], [1 ]])
684
- ztrans = proj3d .proj_transform_vec (zvec , renderer .M )
728
+ ztrans = proj3d ._proj_transform_vec (zvec , renderer .M )
685
729
return ztrans [2 ][0 ]
686
730
elif tzs .size > 0 :
687
731
# FIXME: Some results still don't look quite right.
@@ -734,8 +778,8 @@ def get_edgecolor(self):
734
778
735
779
def poly_collection_2d_to_3d (col , zs = 0 , zdir = 'z' ):
736
780 """Convert a PolyCollection to a Poly3DCollection object."""
737
- segments_3d , codes = paths_to_3d_segments_with_codes ( col . get_paths (),
738
- zs , zdir )
781
+ segments_3d , codes = _paths_to_3d_segments_with_codes (
782
+ col . get_paths (), zs , zdir )
739
783
col .__class__ = Poly3DCollection
740
784
col .set_verts_and_codes (segments_3d , codes )
741
785
col .set_3d_properties ()
@@ -777,14 +821,20 @@ def rotate_axes(xs, ys, zs, zdir):
777
821
return xs , ys , zs
778
822
779
823
780
- def get_colors (c , num ):
824
+ def _get_colors (c , num ):
781
825
"""Stretch the color argument to provide the required number *num*."""
782
826
return np .broadcast_to (
783
827
mcolors .to_rgba_array (c ) if len (c ) else [0 , 0 , 0 , 0 ],
784
828
(num , 4 ))
785
829
786
830
787
- def zalpha (colors , zs ):
831
+ @cbook .deprecated ("3.1" )
832
+ def get_colors (c , num ):
833
+ """Stretch the color argument to provide the required number *num*."""
834
+ return _get_colors (c , num )
835
+
836
+
837
+ def _zalpha (colors , zs ):
788
838
"""Modify the alphas of the color list according to depth."""
789
839
# FIXME: This only works well if the points for *zs* are well-spaced
790
840
# in all three dimensions. Otherwise, at certain orientations,
@@ -796,3 +846,9 @@ def zalpha(colors, zs):
796
846
sats = 1 - norm (zs ) * 0.7
797
847
rgba = np .broadcast_to (mcolors .to_rgba_array (colors ), (len (zs ), 4 ))
798
848
return np .column_stack ([rgba [:, :3 ], rgba [:, 3 ] * sats ])
849
+
850
+
851
+ @cbook .deprecated ("3.1" )
852
+ def zalpha (colors , zs ):
853
+ """Modify the alphas of the color list according to depth."""
854
+ return _zalpha (colors , zs )
0 commit comments