1414import matplotlib .axis as maxis
1515from matplotlib import cbook
1616from matplotlib import docstring
17- from matplotlib .patches import Circle
18- from matplotlib .path import Path
19- from matplotlib .ticker import Formatter , Locator , FormatStrFormatter
20- from matplotlib .transforms import Affine2D , Affine2DBase , Bbox , \
21- BboxTransformTo , IdentityTransform , Transform , TransformWrapper , \
22- ScaledTranslation , blended_transform_factory , BboxTransformToMaxOnly , \
23- nonsingular
17+ import matplotlib .patches as mpatches
18+ import matplotlib .path as mpath
19+ import matplotlib .ticker as mticker
20+ import matplotlib .transforms as mtransforms
2421import matplotlib .spines as mspines
2522
2623
27- class PolarTransform (Transform ):
24+ class PolarTransform (mtransforms . Transform ):
2825 """
2926 The base polar transform. This handles projection *theta* and
3027 *r* into Cartesian coordinate space *x* and *y*, but does not
@@ -36,7 +33,7 @@ class PolarTransform(Transform):
3633 is_separable = False
3734
3835 def __init__ (self , axis = None , use_rmin = True ):
39- Transform .__init__ (self )
36+ mtransforms . Transform .__init__ (self )
4037 self ._axis = axis
4138 self ._use_rmin = use_rmin
4239
@@ -68,22 +65,24 @@ def transform_non_affine(self, tr):
6865 y [:] = np .where (mask , np .nan , r * np .sin (t ))
6966
7067 return xy
71- transform_non_affine .__doc__ = Transform .transform_non_affine .__doc__
68+ transform_non_affine .__doc__ = \
69+ mtransforms .Transform .transform_non_affine .__doc__
7270
7371 def transform_path_non_affine (self , path ):
7472 vertices = path .vertices
7573 if len (vertices ) == 2 and vertices [0 , 0 ] == vertices [1 , 0 ]:
76- return Path (self .transform (vertices ), path .codes )
74+ return mpath . Path (self .transform (vertices ), path .codes )
7775 ipath = path .interpolated (path ._interpolation_steps )
78- return Path (self .transform (ipath .vertices ), ipath .codes )
79- transform_path_non_affine .__doc__ = Transform .transform_path_non_affine .__doc__
76+ return mpath .Path (self .transform (ipath .vertices ), ipath .codes )
77+ transform_path_non_affine .__doc__ = \
78+ mtransforms .Transform .transform_path_non_affine .__doc__
8079
8180 def inverted (self ):
8281 return PolarAxes .InvertedPolarTransform (self ._axis , self ._use_rmin )
83- inverted .__doc__ = Transform .inverted .__doc__
82+ inverted .__doc__ = mtransforms . Transform .inverted .__doc__
8483
8584
86- class PolarAffine (Affine2DBase ):
85+ class PolarAffine (mtransforms . Affine2DBase ):
8786 """
8887 The affine part of the polar projection. Scales the output so
8988 that maximum radius rests on the edge of the axes circle.
@@ -94,7 +93,7 @@ def __init__(self, scale_transform, limits):
9493 its bounds that is used is ymax (for the radius maximum).
9594 The theta range is always fixed to (0, 2pi).
9695 """
97- Affine2DBase .__init__ (self )
96+ mtransforms . Affine2DBase .__init__ (self )
9897 self ._scale_transform = scale_transform
9998 self ._limits = limits
10099 self .set_children (scale_transform , limits )
@@ -104,17 +103,17 @@ def get_matrix(self):
104103 if self ._invalid :
105104 limits_scaled = self ._limits .transformed (self ._scale_transform )
106105 yscale = limits_scaled .ymax - limits_scaled .ymin
107- affine = Affine2D () \
106+ affine = mtransforms . Affine2D () \
108107 .scale (0.5 / yscale ) \
109108 .translate (0.5 , 0.5 )
110109 self ._mtx = affine .get_matrix ()
111110 self ._inverted = None
112111 self ._invalid = 0
113112 return self ._mtx
114- get_matrix .__doc__ = Affine2DBase .get_matrix .__doc__
113+ get_matrix .__doc__ = mtransforms . Affine2DBase .get_matrix .__doc__
115114
116115
117- class InvertedPolarTransform (Transform ):
116+ class InvertedPolarTransform (mtransforms . Transform ):
118117 """
119118 The inverse of the polar transform, mapping Cartesian
120119 coordinate space *x* and *y* back to *theta* and *r*.
@@ -124,7 +123,7 @@ class InvertedPolarTransform(Transform):
124123 is_separable = False
125124
126125 def __init__ (self , axis = None , use_rmin = True ):
127- Transform .__init__ (self )
126+ mtransforms . Transform .__init__ (self )
128127 self ._axis = axis
129128 self ._use_rmin = use_rmin
130129
@@ -160,14 +159,15 @@ def transform_non_affine(self, xy):
160159 r += rmin
161160
162161 return np .concatenate ((theta , r ), 1 )
163- transform_non_affine .__doc__ = Transform .transform_non_affine .__doc__
162+ transform_non_affine .__doc__ = \
163+ mtransforms .Transform .transform_non_affine .__doc__
164164
165165 def inverted (self ):
166166 return PolarAxes .PolarTransform (self ._axis , self ._use_rmin )
167- inverted .__doc__ = Transform .inverted .__doc__
167+ inverted .__doc__ = mtransforms . Transform .inverted .__doc__
168168
169169
170- class ThetaFormatter (Formatter ):
170+ class ThetaFormatter (mticker . Formatter ):
171171 """
172172 Used to format the *theta* tick labels. Converts the native
173173 unit of radians into degrees and adds a degree symbol.
@@ -190,7 +190,7 @@ def __call__(self, x, pos=None):
190190 return format_str .format (value = np .rad2deg (x ), digits = digits )
191191
192192
193- class RadialLocator (Locator ):
193+ class RadialLocator (mticker . Locator ):
194194 """
195195 Used to locate radius ticks.
196196
@@ -229,7 +229,7 @@ def refresh(self):
229229
230230 def view_limits (self , vmin , vmax ):
231231 vmin , vmax = self .base .view_limits (vmin , vmax )
232- return nonsingular (min (0 , vmin ), vmax )
232+ return mtransforms . nonsingular (min (0 , vmin ), vmax )
233233
234234
235235class PolarAxes (Axes ):
@@ -286,11 +286,12 @@ def _init_axis(self):
286286 self ._update_transScale ()
287287
288288 def _set_lim_and_transforms (self ):
289- self .transAxes = BboxTransformTo (self .bbox )
289+ self .transAxes = mtransforms . BboxTransformTo (self .bbox )
290290
291291 # Transforms the x and y axis separately by a scale factor
292292 # It is assumed that this part will have non-linear components
293- self .transScale = TransformWrapper (IdentityTransform ())
293+ self .transScale = mtransforms .TransformWrapper (
294+ mtransforms .IdentityTransform ())
294295
295296 # A (possibly non-linear) projection on the (already scaled)
296297 # data. This one is aware of rmin
@@ -313,14 +314,17 @@ def _set_lim_and_transforms(self):
313314 # the edge of the axis circle.
314315 self ._xaxis_transform = (
315316 self .transPureProjection +
316- self .PolarAffine (IdentityTransform (), Bbox .unit ()) +
317+ self .PolarAffine (mtransforms .IdentityTransform (),
318+ mtransforms .Bbox .unit ()) +
317319 self .transAxes )
318320 # The theta labels are moved from radius == 0.0 to radius == 1.1
319- self ._theta_label1_position = Affine2D ().translate (0.0 , 1.1 )
321+ self ._theta_label1_position = (
322+ mtransforms .Affine2D ().translate (0.0 , 1.1 ))
320323 self ._xaxis_text1_transform = (
321324 self ._theta_label1_position +
322325 self ._xaxis_transform )
323- self ._theta_label2_position = Affine2D ().translate (0.0 , 1.0 / 1.1 )
326+ self ._theta_label2_position = (
327+ mtransforms .Affine2D ().translate (0.0 , 1.0 / 1.1 ))
324328 self ._xaxis_text2_transform = (
325329 self ._theta_label2_position +
326330 self ._xaxis_transform )
@@ -329,14 +333,14 @@ def _set_lim_and_transforms(self):
329333 # axis so the gridlines from 0.0 to 1.0, now go from 0.0 to
330334 # 2pi.
331335 self ._yaxis_transform = (
332- Affine2D ().scale (np .pi * 2.0 , 1.0 ) +
336+ mtransforms . Affine2D ().scale (np .pi * 2.0 , 1.0 ) +
333337 self .transData )
334338 # The r-axis labels are put at an angle and padded in the r-direction
335- self ._r_label_position = ScaledTranslation (
336- self ._default_rlabel_position , 0.0 , Affine2D ())
339+ self ._r_label_position = mtransforms . ScaledTranslation (
340+ self ._default_rlabel_position , 0.0 , mtransforms . Affine2D ())
337341 self ._yaxis_text_transform = (
338342 self ._r_label_position +
339- Affine2D ().scale (1.0 / 360.0 , 1.0 ) +
343+ mtransforms . Affine2D ().scale (1.0 / 360.0 , 1.0 ) +
340344 self ._yaxis_transform
341345 )
342346
@@ -381,7 +385,7 @@ def get_yaxis_text2_transform(self, pad):
381385 return self ._yaxis_text_transform , 'bottom' , 'right'
382386
383387 def _gen_axes_patch (self ):
384- return Circle ((0.5 , 0.5 ), 0.5 )
388+ return mpatches . Circle ((0.5 , 0.5 ), 0.5 )
385389
386390 def _gen_axes_spines (self ):
387391 return {'polar' :mspines .Spine .circular_spine (self ,
@@ -531,7 +535,7 @@ def set_thetagrids(self, angles, labels=None, frac=None, fmt=None,
531535 if labels is not None :
532536 self .set_xticklabels (labels )
533537 elif fmt is not None :
534- self .xaxis .set_major_formatter (FormatStrFormatter (fmt ))
538+ self .xaxis .set_major_formatter (mticker . FormatStrFormatter (fmt ))
535539 if frac is not None :
536540 self ._theta_label1_position .clear ().translate (0.0 , frac )
537541 self ._theta_label2_position .clear ().translate (0.0 , 1.0 / frac )
@@ -571,7 +575,7 @@ def set_rgrids(self, radii, labels=None, angle=None, fmt=None,
571575 if labels is not None :
572576 self .set_yticklabels (labels )
573577 elif fmt is not None :
574- self .yaxis .set_major_formatter (FormatStrFormatter (fmt ))
578+ self .yaxis .set_major_formatter (mticker . FormatStrFormatter (fmt ))
575579 if angle is None :
576580 angle = self .get_rlabel_position ()
577581 self .set_rlabel_position (angle )
0 commit comments