From d14801413f98c1a364888f2924e4c68ec9a5504d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 1 Feb 2026 19:04:44 +0100 Subject: [PATCH 1/4] Add first version of code for gallery example for magnetic rose --- .../gallery/embellishments/magnetic_rose.py | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 examples/gallery/embellishments/magnetic_rose.py diff --git a/examples/gallery/embellishments/magnetic_rose.py b/examples/gallery/embellishments/magnetic_rose.py new file mode 100755 index 00000000000..c57ae71812f --- /dev/null +++ b/examples/gallery/embellishments/magnetic_rose.py @@ -0,0 +1,36 @@ +""" +Magnetic rose +============= + +The method :meth:`pygmt.Figure.magnetic_rose` can be used to add a magnetic rose +to a map or plot. + +""" + +import pygmt + +fig = pygmt.Figure() +fig.basemap(region=[-8, 8, -7, 7], projection="M10c", frame=True) + +# Add a magnetic rose. +# By default, it's placed in the lower left corner. +fig.magnetic_rose() + +# Add a magnetic rose with several adjustments +with pygmt.config( + MAP_TICK_PEN_SECONDARY="orange", + MAP_TICK_PEN_PRIMARY="cyan", + MAP_DEFAULT_PEN="brown", + FONT_TITLE="purple", +): + fig.magnetic_rose( + declination=14.3, + # declination_label="14.3 N°E", # white spaces are not supported + position="MC", + width="4.5c", + labels=["W", "E", "South", "*"], + outer_pen="1p,red", + inner_pen="1p,blue", + ) + +fig.show() From 75ca44b7430edb1e73abd10d9a7324fbc890415f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 1 Feb 2026 19:05:32 +0100 Subject: [PATCH 2/4] Remove execusion permission --- examples/gallery/embellishments/magnetic_rose.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/magnetic_rose.py diff --git a/examples/gallery/embellishments/magnetic_rose.py b/examples/gallery/embellishments/magnetic_rose.py old mode 100755 new mode 100644 From aa344e750e967013206c0d242be5f5724eb9e63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 1 Feb 2026 21:13:01 +0100 Subject: [PATCH 3/4] Add more docs --- examples/gallery/embellishments/magnetic_rose.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/magnetic_rose.py b/examples/gallery/embellishments/magnetic_rose.py index c57ae71812f..1b7b8176b1c 100644 --- a/examples/gallery/embellishments/magnetic_rose.py +++ b/examples/gallery/embellishments/magnetic_rose.py @@ -3,10 +3,10 @@ ============= The method :meth:`pygmt.Figure.magnetic_rose` can be used to add a magnetic rose -to a map or plot. - +to a map or plot. This example shows how such a magnetic rose can be customized. """ +# %% import pygmt fig = pygmt.Figure() From c539929757e946a0b33845314d419dda9a4b795e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 2 Feb 2026 21:01:53 +0100 Subject: [PATCH 4/4] Add comments --- examples/gallery/embellishments/magnetic_rose.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/magnetic_rose.py b/examples/gallery/embellishments/magnetic_rose.py index 1b7b8176b1c..780a760c3b7 100644 --- a/examples/gallery/embellishments/magnetic_rose.py +++ b/examples/gallery/embellishments/magnetic_rose.py @@ -18,18 +18,29 @@ # Add a magnetic rose with several adjustments with pygmt.config( + # Pen used for the ticks related the outer circle and the outline of the North star MAP_TICK_PEN_SECONDARY="orange", + # Pen used for the ticks related to the inner circle MAP_TICK_PEN_PRIMARY="cyan", + # Pen used for the stem of the declination arrow and the fill of the North star MAP_DEFAULT_PEN="brown", + # Font used for the labels for the geographic directions FONT_TITLE="purple", ): fig.magnetic_rose( + position="MC", # placed at MiddleCenter + width=4.5, # width of the rose + # If a declination value is given, a arrow showing the declination is plotted + # instead of the simple North arrow declination=14.3, + # Adjust the label added to the declination arrow # declination_label="14.3 N°E", # white spaces are not supported - position="MC", - width="4.5c", + # Add labels for the geographic directions. Use a * to get a North star. + # Use "" to skip a label. labels=["W", "E", "South", "*"], + # Draw an outer circle with the provided pen outer_pen="1p,red", + # Draw an inner circle with the provided pen inner_pen="1p,blue", )