From 4a8796b33d6a3830e98b01fb6069c22487cf9eb7 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 14 Apr 2018 22:36:19 -0700 Subject: [PATCH] Add PEP8-compliant aliases to transAxes, transData, etc. ax.transAxes / transData / etc. are perhaps one of the most user-facing parts of mpl that are not pep8 compliant. Provide some PEP8-compliant aliases for those (like myself) who are excessively (and unduly?) bothered by that. Note that (quite unusually for myself :-)) I am **not** proposing to deprecate the camelCase names. --- doc/users/next_whats_new/pep8-transattrs.rst | 6 ++++ lib/matplotlib/axes/_base.py | 32 ++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 doc/users/next_whats_new/pep8-transattrs.rst diff --git a/doc/users/next_whats_new/pep8-transattrs.rst b/doc/users/next_whats_new/pep8-transattrs.rst new file mode 100644 index 000000000000..c75dca0f5ab0 --- /dev/null +++ b/doc/users/next_whats_new/pep8-transattrs.rst @@ -0,0 +1,6 @@ +PEP8-compliant ``axes_transform``, etc. aliases to ``transAxes``, etc. +---------------------------------------------------------------------- + +The ``Axes.transAxes``, ``transScale``, ``transLimits``, and ``transData`` +attributes can now also be accessed under the names ``axes_transform``, +``scale_transform``, ``limits_transform``, and ``data_transform``. diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 2bedc1e724e7..2ee4581cd3fb 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -659,6 +659,38 @@ def _set_lim_and_transforms(self): self._yaxis_transform = mtransforms.blended_transform_factory( self.transAxes, self.transData) + @property + def axes_transform(self): + return self.transAxes + + @axes_transform.setter + def axes_transform(self, value): + self.transAxes = value + + @property + def scale_transform(self): + return self.transScale + + @scale_transform.setter + def scale_transform(self, value): + self.transScale = value + + @property + def limits_transform(self): + return self.transLimits + + @limits_transform.setter + def limits_transform(self, value): + self.transLimits = value + + @property + def data_transform(self): + return self.transData + + @data_transform.setter + def data_transform(self, value): + self.transData = value + def get_xaxis_transform(self, which='grid'): """ Get the transformation used for drawing x-axis labels, ticks