MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _update_patch_limits

Method _update_patch_limits

lib/matplotlib/axes/_base.py:2555–2593  ·  view source on GitHub ↗

Update the data limits for the given patch.

(self, patch)

Source from the content-addressed store, hash-verified

2553 return p
2554
2555 def _update_patch_limits(self, patch):
2556 """Update the data limits for the given patch."""
2557 # hist can add zero height Rectangles, which is useful to keep
2558 # the bins, counts and patches lined up, but it throws off log
2559 # scaling. We'll ignore rects with zero height or width in
2560 # the auto-scaling
2561
2562 # cannot check for '==0' since unitized data may not compare to zero
2563 # issue #2150 - we update the limits if patch has non zero width
2564 # or height.
2565 if (isinstance(patch, mpatches.Rectangle) and
2566 ((not patch.get_width()) and (not patch.get_height()))):
2567 return
2568 p = patch.get_path()
2569 # Get all vertices on the path
2570 # Loop through each segment to get extrema for Bezier curve sections
2571 vertices = []
2572 for curve, code in p.iter_bezier(simplify=False):
2573 # Get distance along the curve of any extrema
2574 _, dzeros = curve.axis_aligned_extrema()
2575 # Calculate vertices of start, end and any extrema in between
2576 vertices.append(curve([0, *dzeros, 1]))
2577
2578 if len(vertices):
2579 vertices = np.vstack(vertices)
2580
2581 patch_trf = patch.get_transform()
2582 updatex, updatey = patch_trf.contains_branch_separately(self.transData)
2583 if not (updatex or updatey):
2584 return
2585 if self.name != "rectilinear":
2586 # As in _update_line_limits, but for axvspan.
2587 if updatex and patch_trf == self.get_yaxis_transform():
2588 updatex = False
2589 if updatey and patch_trf == self.get_xaxis_transform():
2590 updatey = False
2591 trf_to_data = patch_trf - self.transData
2592 xys = trf_to_data.transform(vertices)
2593 self.update_datalim(xys, updatex=updatex, updatey=updatey)
2594
2595 def _update_collection_limits(self, collection):
2596 """Update the data limits for the given collection."""

Callers 2

add_patchMethod · 0.95
relimMethod · 0.95

Calls 11

get_yaxis_transformMethod · 0.95
get_xaxis_transformMethod · 0.95
update_datalimMethod · 0.95
iter_bezierMethod · 0.80
axis_aligned_extremaMethod · 0.80
get_widthMethod · 0.45
get_heightMethod · 0.45
get_pathMethod · 0.45
get_transformMethod · 0.45
transformMethod · 0.45

Tested by

no test coverage detected