diff --git a/doc/api/axes_api.rst b/doc/api/axes_api.rst index 3457368fa51c..d2f76e089389 100644 --- a/doc/api/axes_api.rst +++ b/doc/api/axes_api.rst @@ -586,6 +586,11 @@ non-rectilinear Axes. Axes.get_yaxis_text1_transform Axes.get_yaxis_text2_transform + Axes.transAxes + Axes.transScale + Axes.transLimits + Axes.transData + Other ===== diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index fb04d917720f..2d0ae11741f4 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -561,6 +561,65 @@ class _AxesBase(martist.Artist): _subclass_uses_cla = False + @property + def transAxes(self): + """ + Transform object that represents a coordinate system relative + to the axes of a plot. It provides a mapping from coordinates specified + as fractions of the axes' dimensions. The origin of this coordinate + system (0, 0) is located at the bottom-left corner of the axes, while the + top-right corner is represented by the coordinates (1, 1). + """ + return self._transAxes + + @transAxes.setter + def transAxes(self, value): + self._transAxes = value + + @property + def transScale(self): + """ + Transform object that represents the scaling transformation for + the data coordinates within an axes. It is responsible for converting + the data coordinates to scaled coordinates used for rendering the plot. + The transformation incorporates the scaling applied to the data + along both the x-axis and the y-axis. + """ + return self._transScale + + @transScale.setter + def transScale(self, value): + self._transScale = value + + @property + def transLimits(self): + """ + Transform object that represents the transformation from data + coordinates to the coordinate system used for drawing within the axes + limits. It maps the range of data coordinates to the corresponding range + of the axes limits, taking into account any data clipping that might occur. + """ + return self._transLimits + + @transLimits.setter + def transLimits(self, value): + self._transLimits = value + + @property + def transData(self): + """ + Transform object that represents the transformation from data + coordinates to the coordinate system used for drawing within the axes. + It converts the data coordinates of a plot to the corresponding coordinate + values in the drawing space, enabling proper rendering of plot elements + relative to the axes and the figure. + """ + return self._transData + + @transData.setter + def transData(self, value): + self._transData = value + @property def _axis_map(self): """A mapping of axis names, e.g. 'x', to `Axis` instances.""" diff --git a/lib/matplotlib/axes/_base.pyi b/lib/matplotlib/axes/_base.pyi index 7cf5f166ae30..37f5e80aaf23 100644 --- a/lib/matplotlib/axes/_base.pyi +++ b/lib/matplotlib/axes/_base.pyi @@ -46,10 +46,10 @@ class _AxesBase(martist.Artist): yaxis: YAxis bbox: Bbox dataLim: Bbox - transAxes: Transform - transScale: Transform - transLimits: Transform - transData: Transform + _transAxes: Transform + _transScale: Transform + _transLimits: Transform + _transData: Transform ignore_existing_data_limits: bool axison: bool _projection_init: Any @@ -68,6 +68,22 @@ class _AxesBase(martist.Artist): box_aspect: float | None = ..., **kwargs ) -> None: ... + @property + def transAxes(self) -> Transform: ... + @transAxes.setter + def transAxes(self, value: Transform) -> None: ... + @property + def transScale(self) -> Transform: ... + @transScale.setter + def transScale(self, value: Transform) -> None: ... + @property + def transLimits(self) -> Transform: ... + @transLimits.setter + def transLimits(self, value: Transform) -> None: ... + @property + def transData(self) -> Transform: ... + @transData.setter + def transData(self, value: Transform) -> None: ... def get_subplotspec(self) -> SubplotSpec | None: ... def set_subplotspec(self, subplotspec: SubplotSpec) -> None: ... def get_gridspec(self) -> GridSpec | None: ...