1111from matplotlib .projections import PolarAxes
1212from matplotlib .transforms import Affine2D
1313import mpl_toolkits .axisartist as axisartist
14- import mpl_toolkits .axisartist .angle_helper as angle_helper
15- import mpl_toolkits .axisartist .grid_finder as grid_finder
14+ from mpl_toolkits .axisartist import angle_helper , grid_finder
1615from mpl_toolkits .axisartist .grid_helper_curvelinear import GridHelperCurveLinear
1716
1817
1918def setup_axes (fig , rect ):
2019 """Polar projection, but in a rectangular box."""
21-
2220 # see demo_curvelinear_grid.py for details
23- tr = Affine2D ().scale (np .pi / 180. , 1. ) + PolarAxes .PolarTransform ()
24-
25- extreme_finder = angle_helper .ExtremeFinderCycle (20 , 20 ,
26- lon_cycle = 360 ,
27- lat_cycle = None ,
28- lon_minmax = None ,
29- lat_minmax = (0 , np .inf ),
30- )
31-
32- grid_locator1 = angle_helper .LocatorDMS (12 )
33- grid_locator2 = grid_finder .MaxNLocator (5 )
34-
35- tick_formatter1 = angle_helper .FormatterDMS ()
36-
37- grid_helper = GridHelperCurveLinear (tr ,
38- extreme_finder = extreme_finder ,
39- grid_locator1 = grid_locator1 ,
40- grid_locator2 = grid_locator2 ,
41- tick_formatter1 = tick_formatter1
42- )
43-
44- ax1 = fig .add_subplot (
45- rect , axes_class = axisartist .Axes , grid_helper = grid_helper )
46- ax1 .axis [:].set_visible (False )
47- ax1 .set_aspect (1. )
48- ax1 .set_xlim (- 5 , 12 )
49- ax1 .set_ylim (- 5 , 10 )
50-
51- return ax1
21+ grid_helper = GridHelperCurveLinear (
22+ Affine2D ().scale (np .pi / 180. , 1. ) + PolarAxes .PolarTransform (),
23+ extreme_finder = angle_helper .ExtremeFinderCycle (
24+ 20 , 20 ,
25+ lon_cycle = 360 , lat_cycle = None ,
26+ lon_minmax = None , lat_minmax = (0 , np .inf ),
27+ ),
28+ grid_locator1 = angle_helper .LocatorDMS (12 ),
29+ grid_locator2 = grid_finder .MaxNLocator (5 ),
30+ tick_formatter1 = angle_helper .FormatterDMS (),
31+ )
32+ ax = fig .add_subplot (
33+ rect , axes_class = axisartist .Axes , grid_helper = grid_helper ,
34+ aspect = 1 , xlim = (- 5 , 12 ), ylim = (- 5 , 10 ))
35+ ax .axis [:].set_visible (False )
36+ return ax
5237
5338
5439def add_floating_axis1 (ax1 ):
@@ -73,9 +58,6 @@ def add_floating_axis2(ax1):
7358
7459
7560def ann (ax1 , d ):
76- if plt .rcParams ["text.usetex" ]:
77- d = d .replace ("_" , r"\_" )
78-
7961 ax1 .annotate (d , (0.5 , 1 ), (5 , - 5 ),
8062 xycoords = "axes fraction" , textcoords = "offset points" ,
8163 va = "top" , ha = "center" )
0 commit comments