-
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||
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
|
||||||||||||||||||||||||||||
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 eight minor orientations WNW-ESE, NNW-SSE, NNE-SSW, and ENE-WSW | ||||||||||||||||||||||||||||
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. Hm, I think to be consistent with "two pricipal orientations", it should be "four minor orientations".
Suggested change
|
||||||||||||||||||||||||||||
[default is 1]. | ||||||||||||||||||||||||||||
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
Comment on lines
+24
to
+28
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. What's about having a list here?
Suggested change
|
||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
- 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, | ||||||||||||||||||||||||||||
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
|
||||||||||||||||||||||||||||
append your own four comma-separated strings to override the default. | ||||||||||||||||||||||||||||
Comment on lines
+34
to
+35
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
|
||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||
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() |
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.