File tree 1 file changed +39
-0
lines changed
Filter options
lib/matplotlib/projections
1 file changed +39
-0
lines changed
Original file line number Diff line number Diff line change
1
+ from polar import PolarAxes
2
+ from matplotlib import axes
3
+
4
+ class ProjectionRegistry (object ):
5
+ def __init__ (self ):
6
+ self ._all_projection_types = {}
7
+
8
+ def register (self , * projections ):
9
+ for projection in projections :
10
+ name = projection .name
11
+ self ._all_projection_types [name ] = projection
12
+
13
+ def get_projection_class (self , name ):
14
+ return self ._all_projection_types [name ]
15
+
16
+ def get_projection_names (self ):
17
+ names = self ._all_projection_types .keys ()
18
+ names .sort ()
19
+ return names
20
+ projection_registry = ProjectionRegistry ()
21
+
22
+ projection_registry .register (
23
+ axes .Axes ,
24
+ PolarAxes )
25
+
26
+ def get_projection_class (projection ):
27
+ if projection is None :
28
+ projection = 'rectilinear'
29
+
30
+ try :
31
+ return projection_registry .get_projection_class (projection )
32
+ except KeyError :
33
+ raise ValueError ("Unknown projection '%s'" % projection )
34
+
35
+ def projection_factory (projection , figure , rect , ** kwargs ):
36
+ return get_projection_class (projection )(figure , rect , ** kwargs )
37
+
38
+ def get_projection_names ():
39
+ return projection_registry .get_projection_names ()
You can’t perform that action at this time.
0 commit comments