11from __future__ import unicode_literals
2+
3+ import matplotlib .pyplot as plt
24from matplotlib .axes import Axes
3- from matplotlib import cbook
45from matplotlib .patches import Circle
56from matplotlib .path import Path
6- from matplotlib .ticker import Formatter , Locator , NullLocator , FixedLocator , NullFormatter
7- from matplotlib .transforms import Affine2D , Affine2DBase , Bbox , \
8- BboxTransformTo , IdentityTransform , Transform , TransformWrapper
7+ from matplotlib .transforms import Affine2D , BboxTransformTo , Transform
98from matplotlib .projections import register_projection
109import matplotlib .spines as mspines
1110import matplotlib .axis as maxis
@@ -56,8 +55,8 @@ def cla(self):
5655 self .set_longitude_grid_ends (75 )
5756
5857 # Turn off minor ticking altogether
59- self .xaxis .set_minor_locator (NullLocator ())
60- self .yaxis .set_minor_locator (NullLocator ())
58+ self .xaxis .set_minor_locator (plt . NullLocator ())
59+ self .yaxis .set_minor_locator (plt . NullLocator ())
6160
6261 # Do not display ticks -- we only want gridlines and text
6362 self .xaxis .set_ticks_position ('none' )
@@ -283,7 +282,7 @@ def format_coord(self, long, lat):
283282 # \u00b0 : degree symbol
284283 return '%f\u00b0 %s, %f\u00b0 %s' % (abs (lat ), ns , abs (long ), ew )
285284
286- class DegreeFormatter (Formatter ):
285+ class DegreeFormatter (plt . Formatter ):
287286 """
288287 This is a custom formatter that converts the native unit of
289288 radians into (truncated) degrees and adds a degree symbol.
@@ -309,7 +308,7 @@ class -- it provides a more convenient interface to set the
309308 # by degrees.
310309 number = (360.0 / degrees ) + 1
311310 self .xaxis .set_major_locator (
312- FixedLocator (
311+ plt . FixedLocator (
313312 np .linspace (- np .pi , np .pi , number , True )[1 :- 1 ]))
314313 # Set the formatter to display the tick labels in degrees,
315314 # rather than radians.
@@ -327,7 +326,7 @@ class -- it provides a more convenient interface than
327326 # by degrees.
328327 number = (180.0 / degrees ) + 1
329328 self .yaxis .set_major_locator (
330- FixedLocator (
329+ plt . FixedLocator (
331330 np .linspace (- np .pi / 2.0 , np .pi / 2.0 , number , True )[1 :- 1 ]))
332331 # Set the formatter to display the tick labels in degrees,
333332 # rather than radians.
@@ -448,10 +447,9 @@ def inverted(self):
448447register_projection (HammerAxes )
449448
450449# Now make a simple example using the custom projection.
451- from pylab import *
450+ plt .subplot (111 , projection = "custom_hammer" )
451+ p = plt .plot ([- 1 , 1 , 1 ], [- 1 , - 1 , 1 ], "o-" )
452+ plt .grid (True )
452453
453- subplot (111 , projection = "custom_hammer" )
454- p = plot ([- 1 , 1 , 1 ], [- 1 , - 1 , 1 ], "o-" )
455- grid (True )
454+ plt .show ()
456455
457- show ()
0 commit comments