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/9] 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/9] 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/9] 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/9] 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", ) From 4c0c8a20daf2d05044238cc6172f5b1f6fcad74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 15 Feb 2026 17:04:12 +0100 Subject: [PATCH 5/9] Adjust line length --- examples/gallery/embellishments/magnetic_rose.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/gallery/embellishments/magnetic_rose.py b/examples/gallery/embellishments/magnetic_rose.py index 780a760c3b7..faf14a3859c 100644 --- a/examples/gallery/embellishments/magnetic_rose.py +++ b/examples/gallery/embellishments/magnetic_rose.py @@ -2,8 +2,8 @@ Magnetic rose ============= -The method :meth:`pygmt.Figure.magnetic_rose` can be used to add a magnetic rose -to a map or plot. This example shows how such a magnetic rose can be customized. +The method :meth:`pygmt.Figure.magnetic_rose` can be used to add a magnetic rose to a +map. This example shows how such a magnetic rose can be customized. """ # %% @@ -35,8 +35,8 @@ declination=14.3, # Adjust the label added to the declination arrow # declination_label="14.3 N°E", # white spaces are not supported - # Add labels for the geographic directions. Use a * to get a North star. - # Use "" to skip a label. + # Add labels for the geographic directions. Use a * to get a North star and + # "" to skip a label labels=["W", "E", "South", "*"], # Draw an outer circle with the provided pen outer_pen="1p,red", From e54e76666ae5dbf42dfe33a30f6dbf5d351d2537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 12 Mar 2026 22:47:57 +0100 Subject: [PATCH 6/9] Add declination label with white space --- examples/gallery/embellishments/magnetic_rose.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/magnetic_rose.py b/examples/gallery/embellishments/magnetic_rose.py index faf14a3859c..9f959bf6f9a 100644 --- a/examples/gallery/embellishments/magnetic_rose.py +++ b/examples/gallery/embellishments/magnetic_rose.py @@ -34,7 +34,7 @@ # 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 + declination_label="14.3 N°E", # Add labels for the geographic directions. Use a * to get a North star and # "" to skip a label labels=["W", "E", "South", "*"], From 0e5159cbaf22ae9a2839aca465c95acf200919bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 13 Mar 2026 09:43:02 +0100 Subject: [PATCH 7/9] Remove 'move_text' parameter --- examples/gallery/embellishments/colorbar.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index 163ee70ed78..4e6c6be3701 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -47,13 +47,11 @@ # Colorbar placed at Middle Right (MR) outside the plot bounding box, offset by 1 cm # horizontally and 0 cm vertically from anchor point, with a length of 7 cm and # width of 0.5 cm, and a rectangle for NaN values. - # Note that the label 'Elevation' is moved to the opposite side and plotted - # vertically as a column of characters. + # Note that the label 'Elevation' is plotted vertically as a column of characters. position=Position("MR", cstype="outside", offset=(1, 0)), length=7, width=0.5, nan=True, - move_text=["annotations", "label"], label_as_column=True, frame=["x+lElevation", "y+lm"], scale=10, From 019efb66b1c200f83fd9c4ab7e5c885ce1412bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 13 Mar 2026 09:48:43 +0100 Subject: [PATCH 8/9] Revert "Remove 'move_text' parameter" This reverts commit 0e5159cbaf22ae9a2839aca465c95acf200919bd. --- examples/gallery/embellishments/colorbar.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/colorbar.py b/examples/gallery/embellishments/colorbar.py index 4e6c6be3701..163ee70ed78 100644 --- a/examples/gallery/embellishments/colorbar.py +++ b/examples/gallery/embellishments/colorbar.py @@ -47,11 +47,13 @@ # Colorbar placed at Middle Right (MR) outside the plot bounding box, offset by 1 cm # horizontally and 0 cm vertically from anchor point, with a length of 7 cm and # width of 0.5 cm, and a rectangle for NaN values. - # Note that the label 'Elevation' is plotted vertically as a column of characters. + # Note that the label 'Elevation' is moved to the opposite side and plotted + # vertically as a column of characters. position=Position("MR", cstype="outside", offset=(1, 0)), length=7, width=0.5, nan=True, + move_text=["annotations", "label"], label_as_column=True, frame=["x+lElevation", "y+lm"], scale=10, From 2fe0ce961506bc3c1cacbc331ab740c642baf39a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Fri, 13 Mar 2026 14:32:42 +0100 Subject: [PATCH 9/9] Update 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 9f959bf6f9a..7eaa48b81b4 100644 --- a/examples/gallery/embellishments/magnetic_rose.py +++ b/examples/gallery/embellishments/magnetic_rose.py @@ -12,8 +12,8 @@ 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. +# Add a magnetic rose +# By default, it's placed in the lower left corner fig.magnetic_rose() # Add a magnetic rose with several adjustments