Skip to content

Conversation

@seisman
Copy link
Member

@seisman seisman commented Aug 10, 2025

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

import pygmt
from pygmt.params import Position

fig = 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.

@seisman
Copy link
Member Author

seisman commented Dec 17, 2025

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

@github-actions
Copy link
Contributor

github-actions bot commented Dec 19, 2025

Summary of changed images

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

Status Path
added pygmt/tests/baseline/test_magnetic_rose.png
added pygmt/tests/baseline/test_magnetic_rose_complete.png

Image diff(s)

Details

Added images

  • test_magnetic_rose.png

  • test_magnetic_rose_complete.png

Modified images

Path Old New

Report last updated at commit 877be68

@seisman
Copy link
Member Author

seisman commented Dec 19, 2025

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 seisman force-pushed the feature/magnetic_rose branch from 13ea8cb to 98d0a0d Compare December 19, 2025 09:36
seisman and others added 2 commits December 20, 2025 09:10
Co-authored-by: Yvonne Fröhlich <[email protected]>
Co-authored-by: Yvonne Fröhlich <[email protected]>
Co-authored-by: Yvonne Fröhlich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Brand new feature needs review This PR has higher priority and needs review.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants