What to use instead of _autoscaleYon in Matplotlib 3.6.2?

I have just tried running some code from the beginning of the year under MINGW64 python3, and I got:

    set_my_axis(self.ax1, self.start_ylim[0], self.start_ylim[1], 'y')
  File "my_lib.py", line 445, in set_my_axis
    if inax._ymargin and scaley and inax._autoscaleYon:
AttributeError: 'AxesSubplot' object has no attribute '_autoscaleYon'. Did you mean: 'autoscale'?

Great, I love it when this happens! :+1:

This is what I get for version:

$ python3 -c 'import matplotlib; print(matplotlib.__version__)'

So, what should I use instead of the autoscaling setting (Axes._autoscaleYon) now?

Well, easiest was to get the matplotlib source:

git clone https://github.com/matplotlib/matplotlib.git matplotlib_git
cd matplotlib_git/

ā€¦ and then query git for the string _autoscaleYon in code ( How to grep (search) committed code in the Git history - Stack Overflow ) :

$ git grep _autoscaleYon $(git rev-list --all)
e3a8c45db6e81d8ba5d63a0b76e62a767b756128:lib/matplotlib/axes/_axes.py:                scalex=self._autoscaleXon, scaley=self._autoscaleYon)
e3a8c45db6e81d8ba5d63a0b76e62a767b756128:lib/matplotlib/axes/_base.py:            self._autoscaleYon = True
e3a8c45db6e81d8ba5d63a0b76e62a767b756128:lib/matplotlib/axes/_base.py:        return self._autoscaleXon and self._autoscaleYon
e3a8c45db6e81d8ba5d63a0b76e62a767b756128:lib/matplotlib/axes/_base.py:        return self._autoscaleYon
e3a8c45db6e81d8ba5d63a0b76e62a767b756128:lib/matplotlib/axes/_base.py:        self._autoscaleYon = b
e3a8c45db6e81d8ba5d63a0b76e62a767b756128:lib/matplotlib/axes/_base.py:        self._autoscaleYon = b
e3a8c45db6e81d8ba5d63a0b76e62a767b756128:lib/matplotlib/axes/_base.py:                self._autoscaleYon = bool(enable)

ā€¦ then look for an actual code commit line being added or removed ( How do I find the Git commit where some code was removed? - Stack Overflow )

$ git log --oneline -G 'self._autoscaleYon = True'
cc88f311cc Move tracking of autoscale status to Axis.
3fd17270c4 Fix for issue #10062
5e65bbe580 Splitted the axes module into smaller chunks
229e9e9b3f Added ability to turn on/off the autoscale for the X & Y axes independantly.

Finally, one can open gitk --all GUI, and go directly to commit, where one can see:

-        if self._sharex is None:
-            self._autoscaleXon = True
-        if self._sharey is None:
-            self._autoscaleYon = True
         self._xmargin = mpl.rcParams['axes.xmargin']
         self._ymargin = mpl.rcParams['axes.ymargin']
         self._tight = None
@@ -2561,17 +2559,15 @@ class _AxesBase(martist.Artist):
         return self.patch.contains(mouseevent)[0]
+    get_autoscalex_on = _axis_method_wrapper("xaxis", "_get_autoscale_on")
+    get_autoscaley_on = _axis_method_wrapper("yaxis", "_get_autoscale_on")
+    set_autoscalex_on = _axis_method_wrapper("xaxis", "_set_autoscale_on")
+    set_autoscaley_on = _axis_method_wrapper("yaxis", "_set_autoscale_on")

So, instead of ._autoscaleYon property, we should use .get_autoscaley_on() method now.

Iā€™m sorry we broke you @sdbbs , however given that _autoscaleYon is prefixed with an underscore we do not consider that part of our public API and will change it with no warning. This is Python so we can not stop you from accessing these attributes, but you do so at your own risk.