|
1 |
| -import functools |
2 |
| - |
3 | 1 | from matplotlib import _api, docstring
|
4 | 2 | import matplotlib.artist as martist
|
5 | 3 | from matplotlib.axes._axes import Axes
|
@@ -37,15 +35,6 @@ def __init__(self, fig, *args, **kwargs):
|
37 | 35 | # This will also update the axes position.
|
38 | 36 | self.set_subplotspec(SubplotSpec._from_subplot_args(fig, args))
|
39 | 37 |
|
40 |
| - def __reduce__(self): |
41 |
| - # get the first axes class which does not inherit from a subplotbase |
42 |
| - axes_class = next( |
43 |
| - c for c in type(self).__mro__ |
44 |
| - if issubclass(c, Axes) and not issubclass(c, SubplotBase)) |
45 |
| - return (_picklable_subplot_class_constructor, |
46 |
| - (axes_class,), |
47 |
| - self.__getstate__()) |
48 |
| - |
49 | 38 | @_api.deprecated(
|
50 | 39 | "3.4", alternative="get_subplotspec",
|
51 | 40 | addendum="(get_subplotspec returns a SubplotSpec instance.)")
|
@@ -170,59 +159,10 @@ def _make_twin_axes(self, *args, **kwargs):
|
170 | 159 | return twin
|
171 | 160 |
|
172 | 161 |
|
173 |
| -# this here to support cartopy which was using a private part of the |
174 |
| -# API to register their Axes subclasses. |
175 |
| - |
176 |
| -# In 3.1 this should be changed to a dict subclass that warns on use |
177 |
| -# In 3.3 to a dict subclass that raises a useful exception on use |
178 |
| -# In 3.4 should be removed |
179 |
| - |
180 |
| -# The slow timeline is to give cartopy enough time to get several |
181 |
| -# release out before we break them. |
182 |
| -_subplot_classes = {} |
183 |
| - |
184 |
| - |
185 |
| -@functools.lru_cache(None) |
186 |
| -def subplot_class_factory(axes_class=None): |
187 |
| - """ |
188 |
| - Make a new class that inherits from `.SubplotBase` and the |
189 |
| - given axes_class (which is assumed to be a subclass of `.axes.Axes`). |
190 |
| - This is perhaps a little bit roundabout to make a new class on |
191 |
| - the fly like this, but it means that a new Subplot class does |
192 |
| - not have to be created for every type of Axes. |
193 |
| - """ |
194 |
| - if axes_class is None: |
195 |
| - _api.warn_deprecated( |
196 |
| - "3.3", message="Support for passing None to subplot_class_factory " |
197 |
| - "is deprecated since %(since)s; explicitly pass the default Axes " |
198 |
| - "class instead. This will become an error %(removal)s.") |
199 |
| - axes_class = Axes |
200 |
| - try: |
201 |
| - # Avoid creating two different instances of GeoAxesSubplot... |
202 |
| - # Only a temporary backcompat fix. This should be removed in |
203 |
| - # 3.4 |
204 |
| - return next(cls for cls in SubplotBase.__subclasses__() |
205 |
| - if cls.__bases__ == (SubplotBase, axes_class)) |
206 |
| - except StopIteration: |
207 |
| - return type("%sSubplot" % axes_class.__name__, |
208 |
| - (SubplotBase, axes_class), |
209 |
| - {'_axes_class': axes_class}) |
210 |
| - |
211 |
| - |
| 162 | +subplot_class_factory = cbook._make_class_factory( |
| 163 | + SubplotBase, "{}Subplot", "_axes_class", default_axes_class=Axes) |
212 | 164 | Subplot = subplot_class_factory(Axes) # Provided for backward compatibility.
|
213 | 165 |
|
214 |
| - |
215 |
| -def _picklable_subplot_class_constructor(axes_class): |
216 |
| - """ |
217 |
| - Stub factory that returns an empty instance of the appropriate subplot |
218 |
| - class when called with an axes class. This is purely to allow pickling of |
219 |
| - Axes and Subplots. |
220 |
| - """ |
221 |
| - subplot_class = subplot_class_factory(axes_class) |
222 |
| - return subplot_class.__new__(subplot_class) |
223 |
| - |
224 |
| - |
225 | 166 | docstring.interpd.update(Axes_kwdoc=martist.kwdoc(Axes))
|
226 |
| -docstring.dedent_interpd(Axes.__init__) |
227 |
| - |
228 | 167 | docstring.interpd.update(Subplot_kwdoc=martist.kwdoc(Axes))
|
| 168 | +docstring.dedent_interpd(Axes.__init__) |
0 commit comments