1818# code used by a number of projections with similar characteristics
1919# (see geo.py).
2020
21+
2122class HammerAxes (Axes ):
23+
2224 """
2325 A custom class for the Aitoff-Hammer projection, an equal-area map
2426 projection.
@@ -156,16 +158,17 @@ def _set_lim_and_transforms(self):
156158 # (1, ymax). The goal of these transforms is to go from that
157159 # space to display space. The tick labels will be offset 4
158160 # pixels from the edge of the axes ellipse.
159- yaxis_stretch = Affine2D ().scale (np .pi * 2.0 , 1.0 ).translate (- np .pi , 0.0 )
161+ yaxis_stretch = Affine2D ().scale (
162+ np .pi * 2.0 , 1.0 ).translate (- np .pi , 0.0 )
160163 yaxis_space = Affine2D ().scale (1.0 , 1.1 )
161164 self ._yaxis_transform = \
162165 yaxis_stretch + \
163166 self .transData
164167 yaxis_text_base = \
165168 yaxis_stretch + \
166169 self .transProjection + \
167- (yaxis_space + \
168- self .transAffine + \
170+ (yaxis_space +
171+ self .transAffine +
169172 self .transAxes )
170173 self ._yaxis_text1_transform = \
171174 yaxis_text_base + \
@@ -174,12 +177,12 @@ def _set_lim_and_transforms(self):
174177 yaxis_text_base + \
175178 Affine2D ().translate (8.0 , 0.0 )
176179
177- def get_xaxis_transform (self ,which = 'grid' ):
180+ def get_xaxis_transform (self , which = 'grid' ):
178181 """
179182 Override this method to provide a transformation for the
180183 x-axis grid and ticks.
181184 """
182- assert which in ['tick1' ,'tick2' ,'grid' ]
185+ assert which in ['tick1' , 'tick2' , 'grid' ]
183186 return self ._xaxis_transform
184187
185188 def get_xaxis_text1_transform (self , pixelPad ):
@@ -200,12 +203,12 @@ def get_xaxis_text2_transform(self, pixelPad):
200203 """
201204 return self ._xaxis_text2_transform , 'top' , 'center'
202205
203- def get_yaxis_transform (self ,which = 'grid' ):
206+ def get_yaxis_transform (self , which = 'grid' ):
204207 """
205208 Override this method to provide a transformation for the
206209 y-axis grid and ticks.
207210 """
208- assert which in ['tick1' ,'tick2' ,'grid' ]
211+ assert which in ['tick1' , 'tick2' , 'grid' ]
209212 return self ._yaxis_transform
210213
211214 def get_yaxis_text1_transform (self , pixelPad ):
@@ -238,8 +241,8 @@ def _gen_axes_patch(self):
238241 return Circle ((0.5 , 0.5 ), 0.5 )
239242
240243 def _gen_axes_spines (self ):
241- return {'custom_hammer' :mspines .Spine .circular_spine (self ,
242- (0.5 , 0.5 ), 0.5 )}
244+ return {'custom_hammer' : mspines .Spine .circular_spine (self ,
245+ (0.5 , 0.5 ), 0.5 )}
243246
244247 # Prevent the user from applying scales to one or both of the
245248 # axes. In this particular case, scaling the axes wouldn't make
@@ -284,10 +287,12 @@ def format_coord(self, lon, lat):
284287 return '%f\u00b0 %s, %f\u00b0 %s' % (abs (lat ), ns , abs (lon ), ew )
285288
286289 class DegreeFormatter (Formatter ):
290+
287291 """
288292 This is a custom formatter that converts the native unit of
289293 radians into (truncated) degrees and adds a degree symbol.
290294 """
295+
291296 def __init__ (self , round_to = 1.0 ):
292297 self ._round_to = round_to
293298
@@ -369,16 +374,20 @@ def can_zoom(self):
369374 Return True if this axes support the zoom box
370375 """
371376 return False
377+
372378 def start_pan (self , x , y , button ):
373379 pass
380+
374381 def end_pan (self ):
375382 pass
383+
376384 def drag_pan (self , button , key , x , y ):
377385 pass
378386
379387 # Now, the transforms themselves.
380388
381389 class HammerTransform (Transform ):
390+
382391 """
383392 The base Hammer transform.
384393 """
@@ -394,7 +403,7 @@ def transform_non_affine(self, ll):
394403 The input and output are Nx2 numpy arrays.
395404 """
396405 longitude = ll [:, 0 :1 ]
397- latitude = ll [:, 1 :2 ]
406+ latitude = ll [:, 1 :2 ]
398407
399408 # Pre-compute some values
400409 half_long = longitude / 2.0
@@ -417,13 +426,13 @@ def transform_path_non_affine(self, path):
417426 ipath = path .interpolated (path ._interpolation_steps )
418427 return Path (self .transform (ipath .vertices ), ipath .codes )
419428 transform_path_non_affine .__doc__ = \
420- Transform .transform_path_non_affine .__doc__
429+ Transform .transform_path_non_affine .__doc__
421430
422431 if matplotlib .__version__ < '1.2' :
423432 # Note: For compatibility with matplotlib v1.1 and older, you'll
424433 # need to explicitly implement a ``transform`` method as well.
425434 # Otherwise a ``NotImplementedError`` will be raised. This isn't
426- # necessary for v1.2 and newer, however.
435+ # necessary for v1.2 and newer, however.
427436 transform = transform_non_affine
428437
429438 # Similarly, we need to explicitly override ``transform_path`` if
@@ -448,13 +457,13 @@ def transform_non_affine(self, xy):
448457
449458 quarter_x = 0.25 * x
450459 half_y = 0.5 * y
451- z = np .sqrt (1.0 - quarter_x * quarter_x - half_y * half_y )
452- longitude = 2 * np .arctan ((z * x ) / (2.0 * (2.0 * z * z - 1.0 )))
453- latitude = np .arcsin (y * z )
460+ z = np .sqrt (1.0 - quarter_x * quarter_x - half_y * half_y )
461+ longitude = 2 * np .arctan ((z * x ) / (2.0 * (2.0 * z * z - 1.0 )))
462+ latitude = np .arcsin (y * z )
454463 return np .concatenate ((longitude , latitude ), 1 )
455464 transform_non_affine .__doc__ = Transform .transform_non_affine .__doc__
456465
457- # As before, we need to implement the "transform" method for
466+ # As before, we need to implement the "transform" method for
458467 # compatibility with matplotlib v1.1 and older.
459468 if matplotlib .__version__ < '1.2' :
460469 transform = transform_non_affine
@@ -476,4 +485,3 @@ def inverted(self):
476485 plt .grid (True )
477486
478487 plt .show ()
479-
0 commit comments