Skip to content

Commit 9f64cd2

Browse files
DOC: Add gallery example for magnetic rose (#4381)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 28cd791 commit 9f64cd2

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""
2+
Magnetic rose
3+
=============
4+
5+
The method :meth:`pygmt.Figure.magnetic_rose` can be used to add a magnetic rose to a
6+
map. This example shows how such a magnetic rose can be customized.
7+
"""
8+
9+
# %%
10+
import pygmt
11+
12+
fig = pygmt.Figure()
13+
fig.basemap(region=[-8, 8, -7, 7], projection="M10c", frame=True)
14+
15+
# Add a magnetic rose
16+
# By default, it's placed in the lower left corner
17+
fig.magnetic_rose()
18+
19+
# Add a magnetic rose with several adjustments
20+
with pygmt.config(
21+
# Pen used for the ticks on the outer circle and the outline of the North star
22+
MAP_TICK_PEN_SECONDARY="orange",
23+
# Pen used for the ticks related to the inner circle
24+
MAP_TICK_PEN_PRIMARY="cyan",
25+
# Pen used for the stem of the declination arrow and the fill of the North star
26+
MAP_DEFAULT_PEN="brown",
27+
# Font used for the labels for the geographic directions
28+
FONT_TITLE="purple",
29+
):
30+
fig.magnetic_rose(
31+
position="MC", # placed at MiddleCenter
32+
width=4.5, # width of the rose
33+
# If a declination value is given, an arrow showing the declination is plotted
34+
# instead of the simple North arrow
35+
declination=14.3,
36+
# Adjust the label added to the declination arrow
37+
declination_label="14.3 N°E",
38+
# Add labels for the geographic directions. Use a * to get a North star and
39+
# "" to skip a label
40+
labels=["W", "E", "South", "*"],
41+
# Draw an outer circle with the provided pen
42+
outer_pen="1p,red",
43+
# Draw an inner circle with the provided pen
44+
inner_pen="1p,blue",
45+
)
46+
47+
fig.show()

0 commit comments

Comments
 (0)