@@ -867,53 +867,16 @@ def update_from_path(self, path, ignore=None, updatex=True, updatey=True):
867
867
if ignore is None :
868
868
ignore = self ._ignore
869
869
870
- if path .vertices .size == 0 :
870
+ if path .vertices .size == 0 or not ( updatex or updatey ) :
871
871
return
872
872
873
- points ,minpos ,changed = self ._calc_extents_from_path (path ,ignore ,
874
- updatex ,updatey )
875
-
876
- if changed :
877
- self .invalidate ()
878
- if updatex :
879
- self ._points [:,0 ]= points [:,0 ]
880
- self ._minpos [0 ]= minpos [0 ]
881
- if updatey :
882
- self ._points [:,1 ]= points [:,1 ]
883
- self ._minpos [1 ]= minpos [1 ]
884
-
885
- def _calc_extents_from_path (self ,path ,ignore ,updatex = True ,updatey = True ):
886
- """
887
- Calculate the new bounds and minimum positive values for a `Bbox` from
888
- the path.
889
-
890
- Parameters
891
- ----------
892
- path : `~matplotlib.path.Path`
893
- ignore : bool
894
- - When ``True``, ignore the existing bounds of the `Bbox`.
895
- - When ``False``, include the existing bounds of the `Bbox`.
896
- updatex : bool
897
- When ``True``, update the x-values.
898
- updatey : bool
899
- When ``True``, update the y-values.
900
-
901
- Returns
902
- -------
903
- points : (2, 2) array
904
- minpos : (2,) array
905
- changed : bool
906
- """
907
873
if ignore :
908
874
points = np .array ([[np .inf ,np .inf ], [- np .inf ,- np .inf ]])
909
875
minpos = np .array ([np .inf ,np .inf ])
910
876
else :
911
877
points = self ._points .copy ()
912
878
minpos = self ._minpos .copy ()
913
879
914
- if not (updatex or updatey ):
915
- return points ,minpos ,False
916
-
917
880
valid_points = (np .isfinite (path .vertices [...,0 ])
918
881
& np .isfinite (path .vertices [...,1 ]))
919
882
@@ -928,9 +891,14 @@ def _calc_extents_from_path(self, path, ignore, updatex=True, updatey=True):
928
891
points [1 ,1 ]= max (points [1 ,1 ],np .max (y ,initial = - np .inf ))
929
892
minpos [1 ]= min (minpos [1 ],np .min (y [y > 0 ],initial = np .inf ))
930
893
931
- changed = np .any (points != self ._points )or np .any (minpos != self ._minpos )
932
-
933
- return points ,minpos ,changed
894
+ if np .any (points != self ._points )or np .any (minpos != self ._minpos ):
895
+ self .invalidate ()
896
+ if updatex :
897
+ self ._points [:,0 ]= points [:,0 ]
898
+ self ._minpos [0 ]= minpos [0 ]
899
+ if updatey :
900
+ self ._points [:,1 ]= points [:,1 ]
901
+ self ._minpos [1 ]= minpos [1 ]
934
902
935
903
def update_from_data_x (self ,x ,ignore = None ):
936
904
"""