11
11
from matplotlib .projections import PolarAxes
12
12
from matplotlib .transforms import Affine2D
13
13
import 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
16
15
from mpl_toolkits .axisartist .grid_helper_curvelinear import GridHelperCurveLinear
17
16
18
17
19
18
def setup_axes (fig , rect ):
20
19
"""Polar projection, but in a rectangular box."""
21
-
22
20
# 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
52
37
53
38
54
39
def add_floating_axis1 (ax1 ):
@@ -73,9 +58,6 @@ def add_floating_axis2(ax1):
73
58
74
59
75
60
def ann (ax1 , d ):
76
- if plt .rcParams ["text.usetex" ]:
77
- d = d .replace ("_" , r"\_" )
78
-
79
61
ax1 .annotate (d , (0.5 , 1 ), (5 , - 5 ),
80
62
xycoords = "axes fraction" , textcoords = "offset points" ,
81
63
va = "top" , ha = "center" )
0 commit comments