-
Notifications
You must be signed in to change notification settings - Fork 229
DOC: Add gallery example to show usage of map roses #4010
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
Draft
michaelgrund
wants to merge
8
commits into
main
Choose a base branch
from
gallery-map-roses
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+149
−0
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2ea2061
DOC: Add gallery example to usage of map roses
michaelgrund 929b669
rm tws
michaelgrund 5dac68f
Apply suggestions from code review
michaelgrund d1f7d9e
Apply suggestions from code review
michaelgrund b682ff6
Apply suggestions from code review
michaelgrund 0776071
Apply suggestions from code review
michaelgrund a4a5e50
Merge branch 'main' into gallery-map-roses
michaelgrund c23f5c6
Apply suggestions from code review
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,149 @@ | ||||||||||
r""" | ||||||||||
Directional map roses | ||||||||||
========= | ||||||||||
|
||||||||||
The ``rose`` parameter of the :meth:`pygmt.Figure.basemap` and | ||||||||||
:meth:`pygmt.Figure.coast` methods is used to add a directional map | ||||||||||
rose to a map. This example shows how such a map rose can be customized: | ||||||||||
|
||||||||||
- position: **g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**. Set the position | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
of the reference point. Choose from | ||||||||||
|
||||||||||
- **g**: Give map coordinates as *longitude*\/\ *latitude*. | ||||||||||
- **j**\|\ **J**: Specify a two-character (order independent) code. | ||||||||||
Choose from vertical **T**\(op), **M**\(iddle), or **B**\(ottom) and | ||||||||||
horizontal **L**\(eft), **C**\(entre), or **R**\(ight). Lower / | ||||||||||
uppercase **j** / **J** mean inside / outside of the map bounding | ||||||||||
box. | ||||||||||
- **n**: Give normalized bounding box coordinates as *nx*\/\ *ny*. | ||||||||||
- **x**: Give plot coordinates as *x*\/\ *y*. | ||||||||||
|
||||||||||
- width: **+w**. Set the width of the rose in plot coordinates (append | ||||||||||
**i** (inch), **cm** (centimeters), or **p** (points). | ||||||||||
|
||||||||||
- fanciness: **+f**\[level]. Get a "fancy" rose, and optionally specify the | ||||||||||
level of fanciness. Level 1 draws the two principal E-W, N-S orientations, | ||||||||||
2 adds the two intermediate NW-SE and NE-SW orientations, while 3 adds | ||||||||||
the four minor orientations WNW-ESE, NNW-SSE, NNE-SSW, and ENE-WSW | ||||||||||
[Default is 1]. | ||||||||||
|
||||||||||
- justify: **+j**. Set the anchor point. Specify a two-character (order | ||||||||||
independent) code. Choose from vertical **T**\(op), **M**\(iddle), or | ||||||||||
**B**\(ottom) and horizontal **L**\(eft), **C**\(entre), or **R**\(ight). | ||||||||||
|
||||||||||
- label: **+l**\[w,e,s,n]. Label the cardinal points W,E,S,N. Optionally, | ||||||||||
append your own four comma-separated strings to override the default. | ||||||||||
Skip a specific label by leaving it blank. | ||||||||||
|
||||||||||
- offset: **+o**\ *offset* or **+o**\ *xoffset*/\ *yoffset*. Give either a | ||||||||||
common shift or individual shifts in x- (longitude) and y- (latitude) | ||||||||||
directions. | ||||||||||
|
||||||||||
Colors of the map roses can be adjusted using :gmt-term:`MAP_DEFAULT_PEN` | ||||||||||
and :gmt-term:`MAP_TICK_PEN_PRIMARY` via :func:`pygmt.config`. Customizing | ||||||||||
label font and color can be done via :gmt-term:`FONT_TITLE`. | ||||||||||
""" | ||||||||||
import pygmt | ||||||||||
|
||||||||||
fig = pygmt.Figure() | ||||||||||
|
||||||||||
region = [-5,5,-5,5] | ||||||||||
projection = "M?" | ||||||||||
|
||||||||||
with fig.subplot( | ||||||||||
nrows=2, ncols=4, figsize=("20c", "10c"), sharex = True, sharey = True): | ||||||||||
|
||||||||||
# Plain rose of 2.5 cm width showing arrow towards north, a cross | ||||||||||
# indicating the cardinal directions, and corresponding label | ||||||||||
with fig.set_panel(panel=0): | ||||||||||
fig.basemap(region = region, | ||||||||||
projection = projection, | ||||||||||
rose = "g0/0+w2.5c+jCM+l", | ||||||||||
frame = True) | ||||||||||
|
||||||||||
# Fancy, 2.5 cm wide rose of level 1 and labels indicating the different | ||||||||||
# directions | ||||||||||
with fig.set_panel(panel=1): | ||||||||||
|
||||||||||
fig.basemap(region = region, | ||||||||||
projection = projection, | ||||||||||
rose = "g0/0+w2.5c+f1+jCM+l", | ||||||||||
frame = True) | ||||||||||
|
||||||||||
# Fancy, 2.5 cm wide rose of level 2 abels indicating the different | ||||||||||
# directions | ||||||||||
Comment on lines
+73
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
with fig.set_panel(panel=2): | ||||||||||
|
||||||||||
fig.basemap(region = region, | ||||||||||
projection = projection, | ||||||||||
rose = "g0/0+w2.5c+f2+l+jCM", | ||||||||||
frame = True) | ||||||||||
|
||||||||||
# Fancy, 2.5 cm wide rose of level 3 abels indicating the different | ||||||||||
# directions | ||||||||||
Comment on lines
+82
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
with fig.set_panel(panel=3): | ||||||||||
|
||||||||||
fig.basemap(region = region, | ||||||||||
projection = projection, | ||||||||||
rose = "g0/0+w2.5c+f3+l+jCM", | ||||||||||
frame = True) | ||||||||||
|
||||||||||
|
||||||||||
# Plain rose of 2.5 cm width showing arrow towards north, a cross | ||||||||||
# indicating the cardinal directions, and corresponding label. | ||||||||||
# Colors of the rose and labels are defined via | ||||||||||
# MAP_TICK_PEN_PRIMARY and FONT_TITLE, respectively | ||||||||||
with fig.set_panel(panel=4): | ||||||||||
|
||||||||||
with pygmt.config(MAP_TICK_PEN_PRIMARY="purple", | ||||||||||
FONT_TITLE="8p,darkmagenta"): | ||||||||||
|
||||||||||
|
||||||||||
fig.basemap(region = region, | ||||||||||
projection = projection, | ||||||||||
rose = "g0/0+w2.5c+jCM+l", | ||||||||||
frame = True) | ||||||||||
|
||||||||||
# Fancy, 2.5 cm wide rose of level 1 with only one label indicating the North | ||||||||||
# direction. Colors of the rose and labels are defined via | ||||||||||
# MAP_DEFAULT_PEN, MAP_TICK_PEN_PRIMARY and FONT_TITLE, respectively. | ||||||||||
with fig.set_panel(panel=5): | ||||||||||
|
||||||||||
with pygmt.config(MAP_DEFAULT_PEN="default,pink", | ||||||||||
MAP_TICK_PEN_PRIMARY="thick,red3", | ||||||||||
FONT_TITLE="8p,Bookman-Light,red3"): | ||||||||||
|
||||||||||
fig.basemap(region = region, | ||||||||||
projection = projection, | ||||||||||
rose = "g0/0+w2.5c+f1+jCM+l,,,N", | ||||||||||
frame = True) | ||||||||||
|
||||||||||
# Fancy, 2.5 cm wide rose of level 2 with two labels indicating the West and | ||||||||||
# East directions. Colors of the rose and labels are defined via | ||||||||||
# MAP_DEFAULT_PEN, MAP_TICK_PEN_PRIMARY and FONT_TITLE, respectively | ||||||||||
with fig.set_panel(panel=6): | ||||||||||
|
||||||||||
with pygmt.config(MAP_DEFAULT_PEN="default,lightorange", | ||||||||||
MAP_TICK_PEN_PRIMARY="thick,darkorange", | ||||||||||
FONT_TITLE="8p,Bookman-Light,darkorange"): | ||||||||||
|
||||||||||
fig.basemap(region = region, | ||||||||||
projection = projection, | ||||||||||
rose = "g0/0+w2.5c+f2+jCM+lW,E,,", | ||||||||||
frame = True) | ||||||||||
|
||||||||||
# Fancy, 2.5 cm wide rose of level 3 with two labels indicating the North and | ||||||||||
# South directions. Colors of the rose and labels are defined via | ||||||||||
# MAP_DEFAULT_PEN, MAP_TICK_PEN_PRIMARY and FONT_TITLE, respectively | ||||||||||
with fig.set_panel(panel=7): | ||||||||||
|
||||||||||
with pygmt.config(MAP_DEFAULT_PEN="default,Dodgerblue4", | ||||||||||
MAP_TICK_PEN_PRIMARY="thick,Dodgerblue", | ||||||||||
FONT_TITLE="8p,AvantGarde-Demi,Dodgerblue4"): | ||||||||||
|
||||||||||
fig.basemap(region = region, | ||||||||||
projection = projection, | ||||||||||
rose = "g0/0+w2.5c+f3+l,,South,North+jCM", | ||||||||||
frame = True) | ||||||||||
|
||||||||||
fig.show() |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.