@@ -63,40 +63,67 @@ def get_projection_class(projection=None):
6363 raise ValueError ("Unknown projection '%s'" % projection )
6464
6565
66+ def projection_factory (projection , figure , rect , ** kwargs ):
67+ """
68+ Get a new projection instance.
69+
70+ *projection* is a projection name.
71+
72+ *figure* is a figure to add the axes to.
73+
74+ *rect* is a :class:`~matplotlib.transforms.Bbox` object specifying
75+ the location of the axes within the figure.
76+
77+ Any other kwargs are passed along to the specific projection
78+ constructor being used.
79+
80+ .. deprecated::
81+
82+ This routine is deprecated in favour of getting the projection
83+ class directly with :func:`get_projection_class` and initialising it
84+ directly. Will be removed in version 1.3.
85+
86+ """
87+
88+ return get_projection_class (projection )(figure , rect , ** kwargs )
89+
90+
6691def process_projection_requirements (figure , * args , ** kwargs ):
67- """
68- Handle the args/kwargs to for add_axes/add_subplot/gca,
69- returning::
70-
71- (axes_proj_class, proj_class_kwargs, proj_stack_key)
72-
73- Which can be used for new axes initialization/identification.
74-
75- """
76- ispolar = kwargs .pop ('polar' , False )
77- projection = kwargs .pop ('projection' , None )
78- if ispolar :
79- if projection is not None and projection != 'polar' :
80- raise ValueError (
81- "polar=True, yet projection=%r. "
82- "Only one of these arguments should be supplied." %
83- projection )
84- projection = 'polar'
85-
86- if isinstance (projection , basestring ) or projection is None :
87- projection_class = get_projection_class (projection )
88- elif hasattr (projection , '_as_mpl_axes' ):
89- projection_class , extra_kwargs = projection ._as_mpl_axes ()
90- kwargs .update (** extra_kwargs )
91- else :
92- raise TypeError ('projection must be a string, None or implement a '
93- '_as_mpl_axes method. Got %r' % projection )
94-
95- # Make the key without projection kwargs, this is used as a unique
96- # lookup for axes instances
97- key = figure ._make_key (* args , ** kwargs )
92+ """
93+ Handle the args/kwargs to for add_axes/add_subplot/gca,
94+ returning::
95+
96+ (axes_proj_class, proj_class_kwargs, proj_stack_key)
9897
99- return projection_class , kwargs , key
98+ Which can be used for new axes initialization/identification.
99+
100+ .. note:: **kwargs** is modified in place.
101+
102+ """
103+ ispolar = kwargs .pop ('polar' , False )
104+ projection = kwargs .pop ('projection' , None )
105+ if ispolar :
106+ if projection is not None and projection != 'polar' :
107+ raise ValueError (
108+ "polar=True, yet projection=%r. "
109+ "Only one of these arguments should be supplied." %
110+ projection )
111+ projection = 'polar'
112+
113+ if isinstance (projection , basestring ) or projection is None :
114+ projection_class = get_projection_class (projection )
115+ elif hasattr (projection , '_as_mpl_axes' ):
116+ projection_class , extra_kwargs = projection ._as_mpl_axes ()
117+ kwargs .update (** extra_kwargs )
118+ else :
119+ raise TypeError ('projection must be a string, None or implement a '
120+ '_as_mpl_axes method. Got %r' % projection )
121+
122+ # Make the key without projection kwargs, this is used as a unique
123+ # lookup for axes instances
124+ key = figure ._make_key (* args , ** kwargs )
125+
126+ return projection_class , kwargs , key
100127
101128
102129def get_projection_names ():
0 commit comments