Autoscale a single axis. Parameters ---------- axis : Axis The axis to autoscale. v0, v1 : float Data interval limits. minpos : float Minimum positive value for log-scale handling. margin : float
(self, axis, v0, v1, minpos, margin, set_bound, _tight)
| 655 | self.autoscale_view() |
| 656 | |
| 657 | def _autoscale_axis(self, axis, v0, v1, minpos, margin, set_bound, _tight): |
| 658 | """ |
| 659 | Autoscale a single axis. |
| 660 | |
| 661 | Parameters |
| 662 | ---------- |
| 663 | axis : Axis |
| 664 | The axis to autoscale. |
| 665 | v0, v1 : float |
| 666 | Data interval limits. |
| 667 | minpos : float |
| 668 | Minimum positive value for log-scale handling. |
| 669 | margin : float |
| 670 | Margin to apply (e.g., self._xmargin). |
| 671 | set_bound : callable |
| 672 | Function to set the axis bound (e.g., self.set_xbound). |
| 673 | _tight : bool |
| 674 | Whether to use tight bounds. |
| 675 | """ |
| 676 | locator = axis.get_major_locator() |
| 677 | v0, v1 = locator.nonsingular(v0, v1) |
| 678 | # Validate limits for the scale (e.g., positive for log scale) |
| 679 | v0, v1 = axis._scale.limit_range_for_scale(v0, v1, minpos) |
| 680 | if margin > 0: |
| 681 | # Apply margin in transformed space to handle non-linear scales |
| 682 | transform = axis.get_transform() |
| 683 | inverse_trans = transform.inverted() |
| 684 | v0t, v1t = transform.transform([v0, v1]) |
| 685 | delta = (v1t - v0t) * margin |
| 686 | if not np.isfinite(delta): |
| 687 | delta = 0 |
| 688 | v0, v1 = inverse_trans.transform([v0t - delta, v1t + delta]) |
| 689 | if not _tight: |
| 690 | v0, v1 = locator.view_limits(v0, v1) |
| 691 | set_bound(v0, v1, self._view_margin) |
| 692 | |
| 693 | def autoscale_view(self, tight=None, |
| 694 | scalex=True, scaley=True, scalez=True): |
no test coverage detected