Autoscale the view limits using the data limits. Parameters ---------- tight : bool or None If *True*, only expand the axis limits using the margins. Note that unlike for `autoscale`, ``tight=True`` does *not* set the margins to
(self, tight=None, scalex=True, scaley=True)
| 3073 | self._request_autoscale_view("y", tight=tight) |
| 3074 | |
| 3075 | def autoscale_view(self, tight=None, scalex=True, scaley=True): |
| 3076 | """ |
| 3077 | Autoscale the view limits using the data limits. |
| 3078 | |
| 3079 | Parameters |
| 3080 | ---------- |
| 3081 | tight : bool or None |
| 3082 | If *True*, only expand the axis limits using the margins. Note |
| 3083 | that unlike for `autoscale`, ``tight=True`` does *not* set the |
| 3084 | margins to zero. |
| 3085 | |
| 3086 | If *False* and :rc:`axes.autolimit_mode` is 'round_numbers', then |
| 3087 | after expansion by the margins, further expand the axis limits |
| 3088 | using the axis major locator. |
| 3089 | |
| 3090 | If None (the default), reuse the value set in the previous call to |
| 3091 | `autoscale_view` (the initial value is False, but the default style |
| 3092 | sets :rc:`axes.autolimit_mode` to 'data', in which case this |
| 3093 | behaves like True). |
| 3094 | |
| 3095 | scalex : bool, default: True |
| 3096 | Whether to autoscale the x-axis. |
| 3097 | |
| 3098 | scaley : bool, default: True |
| 3099 | Whether to autoscale the y-axis. |
| 3100 | |
| 3101 | Notes |
| 3102 | ----- |
| 3103 | The autoscaling preserves any preexisting axis direction reversal. |
| 3104 | |
| 3105 | The data limits are not updated automatically when artist data are |
| 3106 | changed after the artist has been added to an Axes instance. In that |
| 3107 | case, use :meth:`matplotlib.axes.Axes.relim` prior to calling |
| 3108 | autoscale_view. |
| 3109 | |
| 3110 | If the views of the Axes are fixed, e.g. via `set_xlim`, they will |
| 3111 | not be changed by autoscale_view(). |
| 3112 | See :meth:`matplotlib.axes.Axes.autoscale` for an alternative. |
| 3113 | """ |
| 3114 | if tight is not None: |
| 3115 | self._tight = bool(tight) |
| 3116 | |
| 3117 | x_shared_axes = self._shared_axes["x"].get_siblings(self) |
| 3118 | y_shared_axes = self._shared_axes["y"].get_siblings(self) |
| 3119 | |
| 3120 | x_stickies = y_stickies = np.array([]) |
| 3121 | if self.use_sticky_edges: |
| 3122 | if self._xmargin and scalex and self.get_autoscalex_on(): |
| 3123 | x_sticky = [] |
| 3124 | for ax in x_shared_axes: |
| 3125 | for artist in ax._get_data_children(): |
| 3126 | sticky_edges = artist._sticky_edges |
| 3127 | if sticky_edges is not None and sticky_edges.x: |
| 3128 | x_sticky.extend(sticky_edges.x) |
| 3129 | if x_sticky: |
| 3130 | x_stickies = np.sort(x_sticky) |
| 3131 | if self._ymargin and scaley and self.get_autoscaley_on(): |
| 3132 | y_sticky = [] |