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