Skip to content

Add Figure.magnetic_rose to plot a magnetic rose on map - #4051

Merged
seisman merged 16 commits into
mainfrom
feature/magnetic_rose
Jan 24, 2026
Merged

Add Figure.magnetic_rose to plot a magnetic rose on map#4051
seisman merged 16 commits into
mainfrom
feature/magnetic_rose

Conversation

@seisman

@seismanseisman commented Aug 10, 2025

Copy link
Copy Markdown
Member

This PR implements the Figure.magnetic_rose method to plot a magnetic rose. It wraps the basemap/coast's -Tm option.

Preview: https://pygmt-dev--4051.org.readthedocs.build/en/4051/api/generated/pygmt.Figure.magnetic_rose.html

The GMT CLI syntax is

-Tm[g|j|J|n|x]refpoint[+ddec[/dlabel]]][+ipen][+jjustify][+l[w,e,s,n]][+ppen][+tints][+odx[/dy]][+wwidth]

The Pythonic long-form parameters are:

  • [g|j|J|n|x]refpoint[+jjustify][+odx[/dy]]: position
  • +w: width
  • +p: outer_pen
  • +i: inner_pen
  • +l: labels
  • +d: declination, declination_label
  • +t: intervals

Examples

importpygmtfrompygmt.paramsimportPositionfig=pygmt.Figure()
fig.basemap(region=[-10, 10, -10, 10], projection="M15c", frame=True)
fig.magnetic_rose(
position=Position((-5, -5), cstype="mapcoords"),
width="4c",
labels=["W", "E", "S", "*"],
intervals=(45, 15, 3, 60, 20, 4),
outer_pen="1p,red",
inner_pen="1p,blue",
declination=11.5,
declination_label="11.5°E",
)
fig.show()

Addressing #2831.

Comment threadpygmt/src/magnetic_rose.py
Comment threadpygmt/src/magnetic_rose.py Outdated
Comment threadpygmt/src/magnetic_rose.py
Comment threadpygmt/src/magnetic_rose.py
@seisman

Copy link
Copy Markdown
MemberAuthor

@yvonnefroehlich Please review #4014 first. I'll make further changes to this PR when PR #4014 is finalized.

@github-actions

github-actionsBot commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

StatusPath
addedpygmt/tests/baseline/test_magnetic_rose.png
addedpygmt/tests/baseline/test_magnetic_rose_complete.png

Image diff(s)

Details

Added images

  • test_magnetic_rose.png

  • test_magnetic_rose_complete.png

Modified images

PathOldNew

Report last updated at commit 5dcd644

@seisman

Copy link
Copy Markdown
MemberAuthor

This PR is also ready for review. The key point that we need to discuss is the default position.

As shown below, GMT's default position is x0/0, which looks bad. In PyGMT, the default is jBL which looks pretty good. Need to note that there are some GMT issues with the box.

gmt begin positions png
gmt basemap -R0/20/0/10 -JX20c/10c -Baf
gmt basemap -Tm+w2c
gmt basemap -TmjBL
gmt basemap -TmjBR -F
gmt end show
positions

@seisman
seismanforce-pushed the feature/magnetic_rose branch from 13ea8cb to 98d0a0dCompareDecember 19, 2025 09:36
Comment threadpygmt/src/magnetic_rose.py
Comment threadpygmt/src/magnetic_rose.py Outdated
Comment threadpygmt/src/magnetic_rose.py
Comment threadpygmt/src/magnetic_rose.py Outdated
seismanand others added 2 commits December 20, 2025 09:10
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
seismanand others added 2 commits December 20, 2025 09:11
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
@seismanseisman removed the needs review This PR has higher priority and needs review. label Dec 29, 2025
@seismanseisman modified the milestones: 0.18.0, 0.19.0Dec 29, 2025
@seismanseisman added the needs review This PR has higher priority and needs review. label Jan 12, 2026
@seismanseisman removed the needs review This PR has higher priority and needs review. label Jan 21, 2026

@yvonnefroehlichyvonnefroehlich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Around line 44: Need to add this high-level method to the list after merging the PR for Figure.directional_rose.

Comment threadpygmt/src/basemap.py
@seismanseisman added the final review call This PR requires final review and approval from a second reviewer label Jan 23, 2026
@seismanseisman removed the final review call This PR requires final review and approval from a second reviewer label Jan 24, 2026
@seisman
seisman merged commit d09c5a9 into mainJan 24, 2026
22 of 24 checks passed
@seisman
seisman deleted the feature/magnetic_rose branch January 24, 2026 05:02
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

featureBrand new feature

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants

@seisman@michaelgrund@yvonnefroehlich