Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gallery example to show usage of dcw parameter in Figure.coast #2428

Merged
merged 28 commits into from
Aug 31, 2023
Merged
Changes from 19 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
816efa7
Add gallery example to show usage of dcw parameter in Figure.coast
michaelgrund Mar 15, 2023
9d323f5
[format-command] fixes
actions-bot Mar 15, 2023
732e8f9
Update country_polygons.py
michaelgrund Mar 15, 2023
fc72332
Apply suggestions from code review
michaelgrund May 1, 2023
347b869
Update country_polygons.py
michaelgrund May 5, 2023
c5dafa1
Merge branch 'main' into gallery-dcw
michaelgrund May 5, 2023
a82b0b1
[format-command] fixes
actions-bot May 5, 2023
2c89ed0
Update country_polygons.py
michaelgrund May 5, 2023
28780fe
Apply suggestions from code review
michaelgrund May 5, 2023
6d84c00
Apply suggestions from code review
michaelgrund Aug 9, 2023
0553f7b
Merge branch 'main' into gallery-dcw
michaelgrund Aug 9, 2023
9aaa6c6
Update country_polygons.py
michaelgrund Aug 25, 2023
3f667f6
Merge branch 'main' into gallery-dcw
michaelgrund Aug 25, 2023
0bc785b
Update examples/gallery/maps/country_polygons.py
michaelgrund Aug 26, 2023
5ec5d24
add full country name examples
michaelgrund Aug 29, 2023
19434d5
Merge branch 'main' into gallery-dcw
michaelgrund Aug 29, 2023
6031018
[format-command] fixes
actions-bot Aug 29, 2023
3f1b3b5
Update country_polygons.py
michaelgrund Aug 29, 2023
50ecea3
remove tw
michaelgrund Aug 29, 2023
d59b8d6
Merge branch 'main' into gallery-dcw
michaelgrund Aug 29, 2023
10beaa4
Apply suggestions from code review
michaelgrund Aug 29, 2023
ee8105b
Apply suggestions from code review
michaelgrund Aug 30, 2023
5db6506
Merge branch 'main' into gallery-dcw
michaelgrund Aug 30, 2023
c965eb8
shorten file length
michaelgrund Aug 30, 2023
0318459
Update country_polygons.py
michaelgrund Aug 30, 2023
d24d0f8
Add "state" to title
michaelgrund Aug 30, 2023
2d9ce81
Merge branch 'main' into gallery-dcw
michaelgrund Aug 31, 2023
c7003fa
use thinner linewidth
michaelgrund Aug 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions examples/gallery/maps/country_polygons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
"""
Highlight country and continent polygons
----------------------------------------
The :meth:`pygmt.Figure.coast` method can
highlight country polygons via the ``dcw``
parameter. It accepts the country code or
full country name and can draw its borders
and add a color to its landmass. It's also
possible to define multiple countries at
once by separating the indiviudal names
with commas.
seisman marked this conversation as resolved.
Show resolved Hide resolved
"""

# sphinx_gallery_thumbnail_number = 2


import pygmt

fig = pygmt.Figure()

fig.basemap(
region=[-12, 32, 34, 62],
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
projection="M6c",
frame=True,
)

fig.coast(
land="gray",
water="white",
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
dcw=[
# Great Britain (country code) with seagrean land
"GB+gseagreen",
# Italy with a red border
"IT+p0.75p,red3",
# Spain with a magenta dashed border
"ES+p0.75p,magenta4,-",
# Romania with a black dotted border
"RO+p1p,black,.",
# Germany with orange land and a blue border
"DE+gorange+p1p,dodgerblue4",
# France (full country name) with a steelblue border
"France+p1p,steelblue",
# Norway, Sweden and Finland (multiple countries) with pink
# land and pink3 borders
"Norway,Sweden,Finland+gpink+p0.2p,pink3",
],
)

fig.show()

###############################################################################
# Entire continents can also be highlighted by adding ``"="`` in
# front of the continent code to differentiate it from a country code.

fig = pygmt.Figure()

fig.coast(
region="d",
projection="H10c",
land="gray",
water="white",
frame="afg",
dcw=[
# Europe
"=EU+gseagreen",
# Africa
"=AF+gred3",
# North America
"=NA+gmagenta4",
# South America
"=SA+gorange",
# Asia
"=AS+gdodgerblue4",
# Oceania
"=OC+gtomato",
# Antarctica
"=AN+ggray30",
],
)

fig.show()

###############################################################################
# If available, states/territories of a country can be highlighted, too.

fig = pygmt.Figure()

fig.coast(
region=[-130, -70, 24, 52],
projection="L-100/35/33/45/12c",
land="gray",
shorelines="1/0.5p,gray30",
borders=["1/0.8p,gray30", "2/0.2p,gray30"],
frame=True,
dcw=[
# Texas with orange fill
"US.TX+gorange",
# Kentucky with blue outline
"US.KY+p1p,blue",
],
)

fig.show()