-
Notifications
You must be signed in to change notification settings - Fork 228
Add gallery example to show usage of dcw parameter in Figure.coast #2428
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
Merged
Merged
Changes from 21 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 9d323f5
[format-command] fixes
actions-bot 732e8f9
Update country_polygons.py
michaelgrund fc72332
Apply suggestions from code review
michaelgrund 347b869
Update country_polygons.py
michaelgrund c5dafa1
Merge branch 'main' into gallery-dcw
michaelgrund a82b0b1
[format-command] fixes
actions-bot 2c89ed0
Update country_polygons.py
michaelgrund 28780fe
Apply suggestions from code review
michaelgrund 6d84c00
Apply suggestions from code review
michaelgrund 0553f7b
Merge branch 'main' into gallery-dcw
michaelgrund 9aaa6c6
Update country_polygons.py
michaelgrund 3f667f6
Merge branch 'main' into gallery-dcw
michaelgrund 0bc785b
Update examples/gallery/maps/country_polygons.py
michaelgrund 5ec5d24
add full country name examples
michaelgrund 19434d5
Merge branch 'main' into gallery-dcw
michaelgrund 6031018
[format-command] fixes
actions-bot 3f1b3b5
Update country_polygons.py
michaelgrund 50ecea3
remove tw
michaelgrund d59b8d6
Merge branch 'main' into gallery-dcw
michaelgrund 10beaa4
Apply suggestions from code review
michaelgrund ee8105b
Apply suggestions from code review
michaelgrund 5db6506
Merge branch 'main' into gallery-dcw
michaelgrund c965eb8
shorten file length
michaelgrund 0318459
Update country_polygons.py
michaelgrund d24d0f8
Add "state" to title
michaelgrund 2d9ce81
Merge branch 'main' into gallery-dcw
michaelgrund c7003fa
use thinner linewidth
michaelgrund File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
""" | ||
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. | ||
""" | ||
|
||
# sphinx_gallery_thumbnail_number = 2 | ||
|
||
|
||
import pygmt | ||
|
||
fig = pygmt.Figure() | ||
|
||
fig.coast( | ||
yvonnefroehlich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
region=[-12, 32, 34, 72], | ||
projection="M6c", | ||
land="gray", | ||
water="white", | ||
frame=True, | ||
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() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.