Skip to content

Commit 1df5765

Browse files
willschlitzerseisman
authored and
Josh Sixsmith
committed
Add dcw alias (E) to Figure.coast (GenericMappingTools#765)
Co-authored-by: Dongdong Tian <[email protected]>
1 parent 470e8ac commit 1df5765

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

pygmt/base_plotting.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def _preprocess(self, **kwargs): # pylint: disable=no-self-use
6363
C="lakes",
6464
B="frame",
6565
D="resolution",
66+
E="dcw",
6667
I="rivers",
6768
L="map_scale",
6869
N="borders",
@@ -141,6 +142,25 @@ def coast(self, **kwargs):
141142
shorelines : str
142143
``'[level/]pen'``
143144
Draw shorelines [Default is no shorelines]. Append pen attributes.
145+
dcw : str or list
146+
*code1,code2,…*\ [**+l**\|\ **L**\ ][**+g**\ *fill*\ ]
147+
[**+p**\ *pen*\ ][**+z**]
148+
Select painting or dumping country polygons from the
149+
`Digital Chart of the World
150+
<https://en.wikipedia.org/wiki/Digital_Chart_of_the_World>`__.
151+
Append one or more comma-separated countries using the 2-character
152+
`ISO 3166-1 alpha-2 convention
153+
<https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2>`__.
154+
To select a state of a country (if available), append
155+
.\ *state*, (e.g, US.TX for Texas). To specify a whole continent,
156+
prepend **=** to any of the continent codes (e.g. =EU for Europe).
157+
Append **+p**\ *pen* to draw polygon outlines
158+
(default is no outline) and **+g**\ *fill* to fill them
159+
(default is no fill). Append **+l**\|\ **+L** to *=continent* to
160+
only list countries in that continent; repeat if more than one
161+
continent is requested. Append **+z** to place the country code in
162+
the segment headers via **-Z**\ *code* settings.To apply different
163+
settings to different countries, pass a list of string arguments.
144164
{XY}
145165
{p}
146166
{t}

pygmt/tests/test_coast.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def test_coast_aliases():
5757
Y="a10c",
5858
p="135/25",
5959
t=13,
60+
E="MA+gred",
6061
C="blue",
6162
)
6263
fig_test.coast(
@@ -75,6 +76,7 @@ def test_coast_aliases():
7576
yshift="a10c", # Y
7677
perspective=[135, 25], # p
7778
transparency=13, # t
79+
dcw="MA+gred", # E
7880
lakes="blue", # C
7981
)
8082
return fig_ref, fig_test
@@ -93,3 +95,91 @@ def test_coast_world_mercator():
9395
water="white",
9496
)
9597
return fig
98+
99+
100+
@check_figures_equal()
101+
def test_coast_dcw_single():
102+
"Test passing a single country code to dcw"
103+
fig_ref, fig_test = Figure(), Figure()
104+
# Use single-character arguments for the reference image
105+
fig_ref.coast(R="-10/15/25/44", J="M15c", B="a", G="brown", E="ES+gbisque+pblue")
106+
fig_test.coast(
107+
region=[-10, 15, 25, 44],
108+
frame="a",
109+
projection="M15c",
110+
land="brown",
111+
dcw="ES+gbisque+pblue",
112+
)
113+
return fig_ref, fig_test
114+
115+
116+
@check_figures_equal()
117+
def test_coast_dcw_multiple():
118+
"Test passing multiple country code to dcw"
119+
fig_ref, fig_test = Figure(), Figure()
120+
# Use single-character arguments for the reference image
121+
fig_ref.coast(R="-10/15/25/44", J="M15c", B="a", G="brown", E="ES,IT+gbisque+pblue")
122+
fig_test.coast(
123+
region=[-10, 15, 25, 44],
124+
frame="a",
125+
projection="M15c",
126+
land="brown",
127+
dcw="ES,IT+gbisque+pblue",
128+
)
129+
return fig_ref, fig_test
130+
131+
132+
@check_figures_equal()
133+
def test_coast_dcw_list():
134+
"Test passing a list of country codes and fill options to dcw"
135+
fig_ref, fig_test = Figure(), Figure()
136+
# Use single-character arguments for the reference image
137+
fig_ref.coast(
138+
R="-10/15/25/44",
139+
J="M15c",
140+
B="a",
141+
G="brown",
142+
E=["ES+gbisque+pgreen", "IT+gcyan+pblue"],
143+
)
144+
fig_test.coast(
145+
region=[-10, 15, 25, 44],
146+
frame="a",
147+
projection="M15c",
148+
land="brown",
149+
dcw=["ES+gbisque+pgreen", "IT+gcyan+pblue"],
150+
)
151+
return fig_ref, fig_test
152+
153+
154+
@check_figures_equal()
155+
def test_coast_dcw_continent():
156+
"Test passing a continent code to dcw"
157+
fig_ref, fig_test = Figure(), Figure()
158+
# Use single-character arguments for the reference image
159+
fig_ref.coast(R="-10/15/25/44", J="M15c", B="a", G="brown", E="=AF+gbisque+pblue")
160+
fig_test.coast(
161+
region=[-10, 15, 25, 44],
162+
frame="a",
163+
projection="M15c",
164+
land="brown",
165+
dcw="=AF+gbisque+pblue",
166+
)
167+
return fig_ref, fig_test
168+
169+
170+
@check_figures_equal()
171+
def test_coast_dcw_state():
172+
"Test passing a US state code to dcw"
173+
fig_ref, fig_test = Figure(), Figure()
174+
# Use single-character arguments for the reference image
175+
fig_ref.coast(
176+
R="-75/-69/40/44", J="M15c", B="a", G="brown", E="US.MA+gbisque+pblue"
177+
)
178+
fig_test.coast(
179+
region=[-75, -69, 40, 44],
180+
frame="a",
181+
projection="M15c",
182+
land="brown",
183+
dcw="US.MA+gbisque+pblue",
184+
)
185+
return fig_ref, fig_test

0 commit comments

Comments
 (0)