-
Notifications
You must be signed in to change notification settings - Fork 235
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
Open
michaelgrund
wants to merge
38
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.
+113
−0
Open
Changes from all commits
Commits
Show all changes
38 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 20e5926
Apply suggestions from code review
michaelgrund edc3e43
Use new Figure.directional_rose method
michaelgrund 2df12c7
Merge branch 'main' into gallery-map-roses
michaelgrund 3605a62
Update map_roses.py
michaelgrund 2eced7a
Update map_roses.py
michaelgrund 8cecbf1
Update map_roses.py
michaelgrund 7c00cf9
[format-command] fixes
actions-bot 6b17430
Update map_roses.py
michaelgrund ef363b8
Update map_roses.py
michaelgrund 5fd2e4c
Apply suggestions from code review
michaelgrund 72b8683
Apply suggestions from code review
michaelgrund 5e06f90
Merge branch 'main' into gallery-map-roses
michaelgrund 4c94f88
Merge branch 'main' into gallery-map-roses
michaelgrund 55a7de7
Update examples/gallery/embellishments/map_roses.py
michaelgrund 6f57880
Update map_roses.py
michaelgrund 4f8e06d
Merge branch 'main' into gallery-map-roses
michaelgrund 85b71f4
Apply suggestions from code review
michaelgrund 87f2946
Update map_roses.py
michaelgrund 90d3847
Merge branch 'main' into gallery-map-roses
michaelgrund 97bb8f8
[format-command] fixes
actions-bot 230ca03
Apply suggestions from code review
michaelgrund 1a056fe
Merge branch 'main' into gallery-map-roses
michaelgrund 8ac9b25
Merge branch 'main' into gallery-map-roses
michaelgrund 0e57510
Update map_roses.py
michaelgrund 07d7d1c
Update map_roses.py
michaelgrund 5231d7e
Merge branch 'main' into gallery-map-roses
michaelgrund 4fe66cb
[format-command] fixes
actions-bot f21a46f
Update map_roses.py
michaelgrund c082946
Update examples/gallery/embellishments/map_roses.py
michaelgrund e72b24d
Merge branch 'main' into gallery-map-roses
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
Some comments aren't visible on the classic Files Changed page.
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,113 @@ | ||||||
| """ | ||||||
| Directional map rose | ||||||
| ===================== | ||||||
|
|
||||||
| The :meth:`pygmt.Figure.directional_rose` method allows to add | ||||||
| directional roses on maps. Using ``pygmt.Figure.directional_rose()`` | ||||||
| without any arguments will plot a rose at the bottom left corner, | ||||||
| but this example will focus on customizing its position and | ||||||
| apperance. | ||||||
|
Member
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
|
||||||
|
|
||||||
| 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 | ||||||
| from pygmt.params import Position | ||||||
|
|
||||||
| fig = pygmt.Figure() | ||||||
|
|
||||||
| y0 = 20 | ||||||
| y1 = -5 | ||||||
| width = "1.5c" | ||||||
|
|
||||||
| fig.basemap(region=[-5, 80, -17, 32], projection="M10c", frame=True) | ||||||
|
|
||||||
|
|
||||||
| # Plain rose of 1.5 cm width showing an arrow towards North, a cross | ||||||
| # indicating the cardinal directions, and a label for the North direction | ||||||
| fig.directional_rose( | ||||||
| width=width, labels=True, position=Position((0, y0), cstype="mapcoords") | ||||||
| ) | ||||||
|
|
||||||
| # Fancy, 1.5 cm wide rose of level 1 and labels indicating the different directions | ||||||
| fig.directional_rose( | ||||||
| width=width, | ||||||
| labels=True, | ||||||
| position=Position((20, y0), cstype="mapcoords"), | ||||||
|
Member
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. I wonder if we can use |
||||||
| fancy=True, | ||||||
| ) | ||||||
|
|
||||||
| # Fancy, 1.5 cm wide rose of level 2 and labels indicating the different directions | ||||||
| fig.directional_rose( | ||||||
| width=width, | ||||||
| labels=True, | ||||||
| position=Position((45, y0), cstype="mapcoords"), | ||||||
| fancy=2, | ||||||
| ) | ||||||
|
|
||||||
| # Fancy, 1.5 cm wide rose of level 3 and labels indicating the different directions | ||||||
| fig.directional_rose( | ||||||
| width=width, | ||||||
| labels=True, | ||||||
| position=Position((70, y0), cstype="mapcoords"), | ||||||
| fancy=3, | ||||||
| ) | ||||||
|
|
||||||
| # Plain rose of 1.5 cm width showing an arrow towards North, a cross | ||||||
| # indicating the cardinal directions, and a label for the North direction. | ||||||
| # Colors of the rose and labels are defined via | ||||||
| # MAP_TICK_PEN_PRIMARY and FONT_TITLE, respectively | ||||||
| with pygmt.config(MAP_TICK_PEN_PRIMARY="purple", FONT_TITLE="8p,darkmagenta"): | ||||||
| fig.directional_rose( | ||||||
| width=width, | ||||||
| labels=True, | ||||||
| position=Position((0, y1), cstype="mapcoords"), | ||||||
| ) | ||||||
|
|
||||||
| # Fancy, 1.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 pygmt.config( | ||||||
| MAP_DEFAULT_PEN="default,pink", | ||||||
| MAP_TICK_PEN_PRIMARY="red3", | ||||||
| FONT_TITLE="8p,Bookman-Light,red3", | ||||||
| ): | ||||||
| fig.directional_rose( | ||||||
| width=width, | ||||||
| labels=["", "", "", "N"], | ||||||
| position=Position((20, y1), cstype="mapcoords"), | ||||||
| fancy=True, | ||||||
| ) | ||||||
|
|
||||||
| # Fancy, 1.5 cm wide rose of level 2 with two labels indicating the West and | ||||||
| # East directions | ||||||
| with pygmt.config( | ||||||
| MAP_DEFAULT_PEN="default,lightorange", | ||||||
| MAP_TICK_PEN_PRIMARY="darkorange", | ||||||
| FONT_TITLE="8p,Bookman-Light,darkorange", | ||||||
| ): | ||||||
| fig.directional_rose( | ||||||
| width=width, | ||||||
| labels=["W", "E", "", ""], | ||||||
| position=Position((45, y1), cstype="mapcoords"), | ||||||
| fancy=2, | ||||||
| ) | ||||||
|
|
||||||
| # Fancy, 1.5 cm wide rose of level 3 with two labels indicating the North and | ||||||
| # South directions | ||||||
| with pygmt.config( | ||||||
| MAP_DEFAULT_PEN="default,Dodgerblue4", | ||||||
| MAP_TICK_PEN_PRIMARY="Dodgerblue", | ||||||
| FONT_TITLE="8p,AvantGarde-Demi,Dodgerblue4", | ||||||
| ): | ||||||
| fig.directional_rose( | ||||||
| width=width, | ||||||
| labels=["", "", "South", "North"], | ||||||
| position=Position((70, y1), cstype="mapcoords"), | ||||||
| fancy=3, | ||||||
| ) | ||||||
|
|
||||||
| 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.