2020from . import proj3d
2121
2222
23- def norm_angle (a ):
23+ def _norm_angle (a ):
2424 """Return the given angle normalized to -180 < *a* <= 180 degrees."""
2525 a = (a + 360 ) % 360
2626 if a > 180 :
2727 a = a - 360
2828 return a
2929
3030
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 ):
3238 """Return the given angle normalized to -90 < *a* <= 90 degrees."""
3339 a = (a + 180 ) % 180
3440 if a > 90 :
3541 a = a - 180
3642 return a
3743
3844
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+
3951def get_dir_vector (zdir ):
4052 """
4153 Return a direction vector.
@@ -109,7 +121,7 @@ def draw(self, renderer):
109121 dy = proj [1 ][1 ] - proj [1 ][0 ]
110122 angle = math .degrees (math .atan2 (dy , dx ))
111123 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 ))
113125 mtext .Text .draw (self , renderer )
114126 self .stale = False
115127
@@ -200,7 +212,7 @@ def line_2d_to_3d(line, zs=0, zdir='z'):
200212 line .set_3d_properties (zs , zdir )
201213
202214
203- def path_to_3d_segment (path , zs = 0 , zdir = 'z' ):
215+ def _path_to_3d_segment (path , zs = 0 , zdir = 'z' ):
204216 """Convert a path to a 3D segment."""
205217
206218 zs = np .broadcast_to (zs , len (path ))
@@ -210,16 +222,28 @@ def path_to_3d_segment(path, zs=0, zdir='z'):
210222 return seg3d
211223
212224
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' ):
214232 """Convert paths from a collection object to 3D segments."""
215233
216234 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 )
218236 for path , pathz in zip (paths , zs )]
219237 return segs
220238
221239
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' ):
223247 """Convert a path to a 3D segment with path codes."""
224248
225249 zs = np .broadcast_to (zs , len (path ))
@@ -234,13 +258,19 @@ def path_to_3d_segment_with_codes(path, zs=0, zdir='z'):
234258 return seg3d , list (codes )
235259
236260
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' ):
238268 """
239269 Convert paths from a collection object to 3D segments with path codes.
240270 """
241271
242272 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 )
244274 for path , pathz in zip (paths , zs )]
245275 if segments_codes :
246276 segments , codes = zip (* segments_codes )
@@ -249,6 +279,14 @@ def paths_to_3d_segments_with_codes(paths, zs=0, zdir='z'):
249279 return list (segments ), list (codes )
250280
251281
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+
252290class Line3DCollection (LineCollection ):
253291 """
254292 A collection of 3D lines.
@@ -291,7 +329,7 @@ def draw(self, renderer, project=False):
291329
292330def line_collection_2d_to_3d (col , zs = 0 , zdir = 'z' ):
293331 """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 )
295333 col .__class__ = Line3DCollection
296334 col .set_segments (segments3d )
297335
@@ -350,7 +388,7 @@ def do_3d_projection(self, renderer):
350388 return min (vzs )
351389
352390
353- def get_patch_verts (patch ):
391+ def _get_patch_verts (patch ):
354392 """Return a list of vertices for the path of a patch."""
355393 trans = patch .get_patch_transform ()
356394 path = patch .get_path ()
@@ -361,9 +399,15 @@ def get_patch_verts(patch):
361399 return []
362400
363401
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+
364408def patch_2d_to_3d (patch , z = 0 , zdir = 'z' ):
365409 """Convert a Patch to a Patch3D object."""
366- verts = get_patch_verts (patch )
410+ verts = _get_patch_verts (patch )
367411 patch .__class__ = Patch3D
368412 patch .set_3d_properties (verts , z , zdir )
369413
@@ -427,12 +471,12 @@ def do_3d_projection(self, renderer):
427471 xs , ys , zs = self ._offsets3d
428472 vxs , vys , vzs , vis = proj3d .proj_transform_clip (xs , ys , zs , renderer .M )
429473
430- fcs = (zalpha (self ._facecolor3d , vzs ) if self ._depthshade else
474+ fcs = (_zalpha (self ._facecolor3d , vzs ) if self ._depthshade else
431475 self ._facecolor3d )
432476 fcs = mcolors .to_rgba_array (fcs , self ._alpha )
433477 self .set_facecolors (fcs )
434478
435- ecs = (zalpha (self ._edgecolor3d , vzs ) if self ._depthshade else
479+ ecs = (_zalpha (self ._edgecolor3d , vzs ) if self ._depthshade else
436480 self ._edgecolor3d )
437481 ecs = mcolors .to_rgba_array (ecs , self ._alpha )
438482 self .set_edgecolors (ecs )
@@ -493,12 +537,12 @@ def do_3d_projection(self, renderer):
493537 xs , ys , zs = self ._offsets3d
494538 vxs , vys , vzs , vis = proj3d .proj_transform_clip (xs , ys , zs , renderer .M )
495539
496- fcs = (zalpha (self ._facecolor3d , vzs ) if self ._depthshade else
540+ fcs = (_zalpha (self ._facecolor3d , vzs ) if self ._depthshade else
497541 self ._facecolor3d )
498542 fcs = mcolors .to_rgba_array (fcs , self ._alpha )
499543 self .set_facecolors (fcs )
500544
501- ecs = (zalpha (self ._edgecolor3d , vzs ) if self ._depthshade else
545+ ecs = (_zalpha (self ._edgecolor3d , vzs ) if self ._depthshade else
502546 self ._edgecolor3d )
503547 ecs = mcolors .to_rgba_array (ecs , self ._alpha )
504548 self .set_edgecolors (ecs )
@@ -643,7 +687,7 @@ def do_3d_projection(self, renderer):
643687 self .update_scalarmappable ()
644688 self ._facecolors3d = self ._facecolors
645689
646- txs , tys , tzs = proj3d .proj_transform_vec (self ._vec , renderer .M )
690+ txs , tys , tzs = proj3d ._proj_transform_vec (self ._vec , renderer .M )
647691 xyzlist = [(txs [si :ei ], tys [si :ei ], tzs [si :ei ])
648692 for si , ei in self ._segis ]
649693
@@ -681,7 +725,7 @@ def do_3d_projection(self, renderer):
681725 # Return zorder value
682726 if self ._sort_zpos is not None :
683727 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 )
685729 return ztrans [2 ][0 ]
686730 elif tzs .size > 0 :
687731 # FIXME: Some results still don't look quite right.
@@ -734,8 +778,8 @@ def get_edgecolor(self):
734778
735779def poly_collection_2d_to_3d (col , zs = 0 , zdir = 'z' ):
736780 """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 )
739783 col .__class__ = Poly3DCollection
740784 col .set_verts_and_codes (segments_3d , codes )
741785 col .set_3d_properties ()
@@ -777,14 +821,20 @@ def rotate_axes(xs, ys, zs, zdir):
777821 return xs , ys , zs
778822
779823
780- def get_colors (c , num ):
824+ def _get_colors (c , num ):
781825 """Stretch the color argument to provide the required number *num*."""
782826 return np .broadcast_to (
783827 mcolors .to_rgba_array (c ) if len (c ) else [0 , 0 , 0 , 0 ],
784828 (num , 4 ))
785829
786830
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 ):
788838 """Modify the alphas of the color list according to depth."""
789839 # FIXME: This only works well if the points for *zs* are well-spaced
790840 # in all three dimensions. Otherwise, at certain orientations,
@@ -796,3 +846,9 @@ def zalpha(colors, zs):
796846 sats = 1 - norm (zs ) * 0.7
797847 rgba = np .broadcast_to (mcolors .to_rgba_array (colors ), (len (zs ), 4 ))
798848 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