@@ -310,14 +310,6 @@ def _split_path_and_get_label_rotation(self, path, idx, screen_pos, lw, spacing=
310310 determine rotation and then to break contour if desired. The extra spacing is
311311 taken into account when breaking the path, but not when computing the angle.
312312 """
313- if hasattr (self , "_old_style_split_collections" ):
314- vis = False
315- for coll in self ._old_style_split_collections :
316- vis |= coll .get_visible ()
317- coll .remove ()
318- self .set_visible (vis )
319- del self ._old_style_split_collections # Invalidate them.
320-
321313 xys = path .vertices
322314 codes = path .codes
323315
@@ -406,97 +398,6 @@ def interp_vec(x, xp, fp): return [np.interp(x, xp, col) for col in fp.T]
406398
407399 return angle , Path (xys , codes )
408400
409- @_api .deprecated ("3.8" )
410- def calc_label_rot_and_inline (self , slc , ind , lw , lc = None , spacing = 5 ):
411- """
412- Calculate the appropriate label rotation given the linecontour
413- coordinates in screen units, the index of the label location and the
414- label width.
415-
416- If *lc* is not None or empty, also break contours and compute
417- inlining.
418-
419- *spacing* is the empty space to leave around the label, in pixels.
420-
421- Both tasks are done together to avoid calculating path lengths
422- multiple times, which is relatively costly.
423-
424- The method used here involves computing the path length along the
425- contour in pixel coordinates and then looking approximately (label
426- width / 2) away from central point to determine rotation and then to
427- break contour if desired.
428- """
429-
430- if lc is None :
431- lc = []
432- # Half the label width
433- hlw = lw / 2.0
434-
435- # Check if closed and, if so, rotate contour so label is at edge
436- closed = _is_closed_polygon (slc )
437- if closed :
438- slc = np .concatenate ([slc [ind :- 1 ], slc [:ind + 1 ]])
439- if len (lc ): # Rotate lc also if not empty
440- lc = np .concatenate ([lc [ind :- 1 ], lc [:ind + 1 ]])
441- ind = 0
442-
443- # Calculate path lengths
444- pl = np .zeros (slc .shape [0 ], dtype = float )
445- dx = np .diff (slc , axis = 0 )
446- pl [1 :] = np .cumsum (np .hypot (dx [:, 0 ], dx [:, 1 ]))
447- pl = pl - pl [ind ]
448-
449- # Use linear interpolation to get points around label
450- xi = np .array ([- hlw , hlw ])
451- if closed : # Look at end also for closed contours
452- dp = np .array ([pl [- 1 ], 0 ])
453- else :
454- dp = np .zeros_like (xi )
455-
456- # Get angle of vector between the two ends of the label - must be
457- # calculated in pixel space for text rotation to work correctly.
458- (dx ,), (dy ,) = (np .diff (np .interp (dp + xi , pl , slc_col ))
459- for slc_col in slc .T )
460- rotation = np .rad2deg (np .arctan2 (dy , dx ))
461-
462- if self .rightside_up :
463- # Fix angle so text is never upside-down
464- rotation = (rotation + 90 ) % 180 - 90
465-
466- # Break contour if desired
467- nlc = []
468- if len (lc ):
469- # Expand range by spacing
470- xi = dp + xi + np .array ([- spacing , spacing ])
471-
472- # Get (integer) indices near points of interest; use -1 as marker
473- # for out of bounds.
474- I = np .interp (xi , pl , np .arange (len (pl )), left = - 1 , right = - 1 )
475- I = [np .floor (I [0 ]).astype (int ), np .ceil (I [1 ]).astype (int )]
476- if I [0 ] != - 1 :
477- xy1 = [np .interp (xi [0 ], pl , lc_col ) for lc_col in lc .T ]
478- if I [1 ] != - 1 :
479- xy2 = [np .interp (xi [1 ], pl , lc_col ) for lc_col in lc .T ]
480-
481- # Actually break contours
482- if closed :
483- # This will remove contour if shorter than label
484- if all (i != - 1 for i in I ):
485- nlc .append (np .vstack ([xy2 , lc [I [1 ]:I [0 ]+ 1 ], xy1 ]))
486- else :
487- # These will remove pieces of contour if they have length zero
488- if I [0 ] != - 1 :
489- nlc .append (np .vstack ([lc [:I [0 ]+ 1 ], xy1 ]))
490- if I [1 ] != - 1 :
491- nlc .append (np .vstack ([xy2 , lc [I [1 ]:]]))
492-
493- # The current implementation removes contours completely
494- # covered by labels. Uncomment line below to keep
495- # original contour if this is the preferred behavior.
496- # if not len(nlc): nlc = [lc]
497-
498- return rotation , nlc
499-
500401 def add_label (self , x , y , rotation , lev , cvalue ):
501402 """Add a contour label, respecting whether *use_clabeltext* was set."""
502403 data_x , data_y = self .axes .transData .inverted ().transform ((x , y ))
@@ -519,12 +420,6 @@ def add_label(self, x, y, rotation, lev, cvalue):
519420 # Add label to plot here - useful for manual mode label selection
520421 self .axes .add_artist (t )
521422
522- @_api .deprecated ("3.8" , alternative = "add_label" )
523- def add_label_clabeltext (self , x , y , rotation , lev , cvalue ):
524- """Add contour label with `.Text.set_transform_rotates_text`."""
525- with cbook ._setattr_cm (self , _use_clabeltext = True ):
526- self .add_label (x , y , rotation , lev , cvalue )
527-
528423 def add_label_near (self , x , y , inline = True , inline_spacing = 5 ,
529424 transform = None ):
530425 """
@@ -604,15 +499,6 @@ def remove(self):
604499 text .remove ()
605500
606501
607- def _is_closed_polygon (X ):
608- """
609- Return whether first and last object in a sequence are the same. These are
610- presumably coordinates on a polygonal curve, in which case this function
611- tests if that curve is closed.
612- """
613- return np .allclose (X [0 ], X [- 1 ], rtol = 1e-10 , atol = 1e-13 )
614-
615-
616502def _find_closest_point_on_path (xys , p ):
617503 """
618504 Parameters
@@ -906,57 +792,9 @@ def __init__(self, ax, *args,
906792 allkinds = property (lambda self : [
907793 [subp .codes for subp in p ._iter_connected_components ()]
908794 for p in self .get_paths ()])
909- tcolors = _api .deprecated ("3.8" )(property (lambda self : [
910- (tuple (rgba ),) for rgba in self .to_rgba (self .cvalues , self .alpha )]))
911- tlinewidths = _api .deprecated ("3.8" )(property (lambda self : [
912- (w ,) for w in self .get_linewidths ()]))
913795 alpha = property (lambda self : self .get_alpha ())
914796 linestyles = property (lambda self : self ._orig_linestyles )
915797
916- @_api .deprecated ("3.8" , alternative = "set_antialiased or get_antialiased" ,
917- addendum = "Note that get_antialiased returns an array." )
918- @property
919- def antialiased (self ):
920- return all (self .get_antialiased ())
921-
922- @antialiased .setter
923- def antialiased (self , aa ):
924- self .set_antialiased (aa )
925-
926- @_api .deprecated ("3.8" )
927- @property
928- def collections (self ):
929- # On access, make oneself invisible and instead add the old-style collections
930- # (one PathCollection per level). We do not try to further split contours into
931- # connected components as we already lost track of what pairs of contours need
932- # to be considered as single units to draw filled regions with holes.
933- if not hasattr (self , "_old_style_split_collections" ):
934- self .set_visible (False )
935- fcs = self .get_facecolor ()
936- ecs = self .get_edgecolor ()
937- lws = self .get_linewidth ()
938- lss = self .get_linestyle ()
939- self ._old_style_split_collections = []
940- for idx , path in enumerate (self ._paths ):
941- pc = mcoll .PathCollection (
942- [path ] if len (path .vertices ) else [],
943- alpha = self .get_alpha (),
944- antialiaseds = self ._antialiaseds [idx % len (self ._antialiaseds )],
945- transform = self .get_transform (),
946- zorder = self .get_zorder (),
947- label = "_nolegend_" ,
948- facecolor = fcs [idx ] if len (fcs ) else "none" ,
949- edgecolor = ecs [idx ] if len (ecs ) else "none" ,
950- linewidths = [lws [idx % len (lws )]],
951- linestyles = [lss [idx % len (lss )]],
952- )
953- if self .filled :
954- pc .set (hatch = self .hatches [idx % len (self .hatches )])
955- self ._old_style_split_collections .append (pc )
956- for col in self ._old_style_split_collections :
957- self .axes .add_collection (col )
958- return self ._old_style_split_collections
959-
960798 def get_transform (self ):
961799 """Return the `.Transform` instance used by this ContourSet."""
962800 if self ._transform is None :
0 commit comments