Skip to content
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2ea2061
DOC: Add gallery example to usage of map roses
michaelgrund Jul 23, 2025
929b669
rm tws
michaelgrund Jul 23, 2025
5dac68f
Apply suggestions from code review
michaelgrund Jul 24, 2025
d1f7d9e
Apply suggestions from code review
michaelgrund Jul 28, 2025
b682ff6
Apply suggestions from code review
michaelgrund Jul 28, 2025
0776071
Apply suggestions from code review
michaelgrund Jul 28, 2025
a4a5e50
Merge branch 'main' into gallery-map-roses
michaelgrund Jul 28, 2025
c23f5c6
Apply suggestions from code review
michaelgrund Jul 28, 2025
20e5926
Apply suggestions from code review
michaelgrund Jan 28, 2026
edc3e43
Use new Figure.directional_rose method
michaelgrund Jan 28, 2026
2df12c7
Merge branch 'main' into gallery-map-roses
michaelgrund Jan 28, 2026
3605a62
Update map_roses.py
michaelgrund Jan 28, 2026
2eced7a
Update map_roses.py
michaelgrund Jan 28, 2026
8cecbf1
Update map_roses.py
michaelgrund Jan 28, 2026
7c00cf9
[format-command] fixes
actions-bot Jan 28, 2026
6b17430
Update map_roses.py
michaelgrund Jan 28, 2026
ef363b8
Update map_roses.py
michaelgrund Jan 28, 2026
5fd2e4c
Apply suggestions from code review
michaelgrund Jan 29, 2026
72b8683
Apply suggestions from code review
michaelgrund Jan 29, 2026
5e06f90
Merge branch 'main' into gallery-map-roses
michaelgrund Jan 29, 2026
4c94f88
Merge branch 'main' into gallery-map-roses
michaelgrund Jan 29, 2026
55a7de7
Update examples/gallery/embellishments/map_roses.py
michaelgrund Jan 29, 2026
6f57880
Update map_roses.py
michaelgrund Jan 29, 2026
4f8e06d
Merge branch 'main' into gallery-map-roses
michaelgrund Jan 29, 2026
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
115 changes: 115 additions & 0 deletions examples/gallery/embellishments/map_roses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"""
Directional map roses
=====================

The :meth:`pygmt.Figure.directional_rose` method allows to add
directional roses on maps when using :meth:`pygmt.Figure.basemap`
or :meth:`pygmt.Figure.coast`. This example shows how such a map
Comment on lines +5 to +7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not mention basemap/coast.

Suggested change
The :meth:`pygmt.Figure.directional_rose` method allows to add
directional roses on maps when using :meth:`pygmt.Figure.basemap`
or :meth:`pygmt.Figure.coast`. This example shows how such a map
The :meth:`pygmt.Figure.directional_rose` method allows to add
directional roses on maps. This example shows how such a map

rose can be customized.

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 = 0
width = "1.5c"

fig.basemap(region=[-5, 80, -10, 32], projection="M10c", frame=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should have an example like Figure.magnetic_rose() without any arguments? It's the simplest way to use this method.


# 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"),
fancy=True,
)

# Fancy, 1.5 cm wide rose of level 2 and labels indicating the different
# directions
Comment on lines +41 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Fancy, 1.5 cm wide rose of level 2 and labels indicating the different
# directions
# Fancy, 1.5 cm wide rose of level 2 and labels indicating the different directions

or maybe just something similar to

Suggested change
# Fancy, 1.5 cm wide rose of level 2 and labels indicating the different
# directions
# Same rose but now of level 2

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
Comment on lines +50 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Fancy, 1.5 cm wide rose of level 3 and labels indicating the different
# directions
# Fancy, 1.5 cm wide rose of level 3 and labels indicating the different directions

or maybe just something similar to

Suggested change
# Fancy, 1.5 cm wide rose of level 3 and labels indicating the different
# directions
# Same rose but now of level 3

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. Colors of the rose and labels are defined via
# MAP_DEFAULT_PEN, MAP_TICK_PEN_PRIMARY and FONT_TITLE, respectively
Comment on lines +85 to +87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As these defaults were explained in the example before and are mentioned in the introduction text, I feel we do not need to repeat it for the following examples.

Suggested change
# Fancy, 1.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
# 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. Colors of the rose and labels are defined via
# MAP_DEFAULT_PEN, MAP_TICK_PEN_PRIMARY and FONT_TITLE, respectively
Comment on lines +100 to +102
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Fancy, 1.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
# 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()