Update the data limits for the given patch.
(self, patch)
| 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.""" |
no test coverage detected