Skip to content

Commit 8fa1a97

Browse files
Improve example for Polar projection (#2110)
Co-authored-by: Dongdong Tian <[email protected]>
1 parent c5bb7ae commit 8fa1a97

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

examples/projections/nongeo/polar.py

+37-38
Original file line numberDiff line numberDiff line change
@@ -52,60 +52,57 @@
5252

5353
fig = pygmt.Figure()
5454

55-
pygmt.config(FONT_TITLE="14p,Helvetica,black", FORMAT_GEO_MAP="+D")
55+
pygmt.config(FONT_TITLE="14p,Courier,black", FORMAT_GEO_MAP="+D")
5656

5757
# ============
58-
58+
# top left
5959
fig.basemap(
6060
# set map limits to theta_min = 0, theta_max = 360, radius_min = 0,
6161
# radius_max = 1
6262
region=[0, 360, 0, 1],
6363
# set map width to 5 cm
6464
projection="P5c",
65-
# set the frame and color
66-
frame=["xa45f", "+gbisque"],
65+
# set the frame, color, and title
66+
# @^ allows for a line break within the title
67+
frame=["xa45f", "+gbisque+tprojection='P5c' @^ region=[0, 360, 0, 1]"],
6768
)
6869

69-
fig.text(position="TC", text="projection='P5c'", offset="0/2.0c", no_clip=True)
70-
fig.text(position="TC", text="region=[0, 360, 0, 1]", offset="0/1.5c", no_clip=True)
71-
7270
fig.shift_origin(xshift="8c")
7371

7472
# ============
73+
# top middle
7574
fig.basemap(
7675
# set map limits to theta_min = 0, theta_max = 360, radius_min = 0,
7776
# radius_max = 1
7877
region=[0, 360, 0, 1],
7978
# set map width to 5 cm and interpret input data as geographic azimuth
8079
# instead of standard angle
8180
projection="P5c+a",
82-
# set the frame and color
83-
frame=["xa45f", "+gbisque"],
81+
# set the frame, color, and title
82+
# @^ allows for a line break within the title
83+
frame=["xa45f", "+gbisque+tprojection='P5c+a' @^ region=[0, 360, 0, 1]"],
8484
)
8585

86-
fig.text(position="TC", text="projection='P5c+a'", offset="0/2.0c", no_clip=True)
87-
fig.text(position="TC", text="region=[0, 360, 0, 1]", offset="0/1.5c", no_clip=True)
88-
8986
fig.shift_origin(xshift="8c")
9087

9188
# ============
89+
# top right
9290
fig.basemap(
9391
# set map limits to theta_min = 0, theta_max = 90, radius_min = 0,
9492
# radius_max = 1
9593
region=[0, 90, 0, 1],
9694
# set map width to 5 cm and interpret input data as geographic azimuth
9795
# instead of standard angle
9896
projection="P5c+a",
99-
# set the frame and color
100-
frame=["xa45f", "ya0.2", "WNe+gbisque"],
97+
# set the frame, color, and title
98+
# @^ allows for a line break within the title
99+
frame=["xa45f", "ya0.2", "WNe+gbisque+tprojection='P5c+a' @^ region=[0, 90, 0, 1]"],
101100
)
102101

103-
fig.text(position="TC", text="projection='P5c+a'", offset="0/2.0c", no_clip=True)
104-
fig.text(position="TC", text="region=[0, 90, 0, 1]", offset="0/1.5c", no_clip=True)
105-
106102
fig.shift_origin(xshift="-16c", yshift="-7c")
107103

108104
# ============
105+
# bottom left
109106
fig.basemap(
110107
# set map limits to theta_min = 0, theta_max = 90, radius_min = 0,
111108
# radius_max = 1
@@ -114,16 +111,19 @@
114111
# instead of standard angle, rotate coordinate system counterclockwise by
115112
# 45 degrees
116113
projection="P5c+a+t45",
117-
# set the frame and color
118-
frame=["xa30f", "ya0.2", "WNe+gbisque"],
114+
# set the frame, color, and title
115+
# @^ allows for a line break within the title
116+
frame=[
117+
"xa30f",
118+
"ya0.2",
119+
"WNe+gbisque+tprojection='P5c+a+t45' @^ region=[0, 90, 0, 1]",
120+
],
119121
)
120122

121-
fig.text(position="TC", text=r"projection='P5c+a\+t45'", offset="0/2.0c", no_clip=True)
122-
fig.text(position="TC", text="region=[0, 90, 0, 1]", offset="0/1.5c", no_clip=True)
123-
124123
fig.shift_origin(xshift="8c", yshift="1.3c")
125124

126125
# ============
126+
# bottom middle
127127
fig.basemap(
128128
# set map limits to theta_min = 0, theta_max = 90, radius_min = 3480,
129129
# radius_max = 6371 (Earth's radius)
@@ -132,18 +132,19 @@
132132
# instead of standard angle, rotate coordinate system counterclockwise by
133133
# 45 degrees
134134
projection="P5c+a+t45",
135-
# set the frame and color
136-
frame=["xa30f", "ya", "WNse+gbisque"],
137-
)
138-
139-
fig.text(position="TC", text=r"projection='P5c+a\+t45'", offset="0/2.0c", no_clip=True)
140-
fig.text(
141-
position="TC", text="region=[0, 90, 3480, 6371]", offset="0/1.5c", no_clip=True
135+
# set the frame, color, and title
136+
# @^ allows for a line break within the title
137+
frame=[
138+
"xa30f",
139+
"ya",
140+
"WNse+gbisque+tprojection='P5c+a+t45' @^ region=[0, 90, 3480, 6371]",
141+
],
142142
)
143143

144144
fig.shift_origin(xshift="8c")
145145

146146
# ============
147+
# bottom right
147148
fig.basemap(
148149
# set map limits to theta_min = 0, theta_max = 90, radius_min = 3480,
149150
# radius_max = 6371 (Earth's radius)
@@ -152,15 +153,13 @@
152153
# instead of standard angle, rotate coordinate system counterclockwise by
153154
# 45 degrees, r-axis is marked as depth
154155
projection="P5c+a+t45+z",
155-
# set the frame and color
156-
frame=["xa30f", "ya", "WNse+gbisque"],
157-
)
158-
159-
fig.text(
160-
position="TC", text=r"projection='P5c+a\+t45+z'", offset="0/2.0c", no_clip=True
161-
)
162-
fig.text(
163-
position="TC", text="region=[0, 90, 3480, 6371]", offset="0/1.5c", no_clip=True
156+
# set the frame, color, and title
157+
# @^ allows for a line break within the title
158+
frame=[
159+
"xa30f",
160+
"ya",
161+
"WNse+gbisque+tprojection='P5c+a+t45+\\z' @^ region=[0, 90, 3480, 6371]",
162+
],
164163
)
165164

166165
fig.show()

0 commit comments

Comments
 (0)