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 seisman force-pushed the feature/magnetic_rose branch from a525760 to be5f819 Compare December 15, 2025 07:23
@seisman seisman added the needs review This PR has higher priority and needs review. label Dec 15, 2025
@seisman seisman marked this pull request as ready for review December 15, 2025 07:23
Comment on lines +46 to +47
star is plotted instead of the north label. If set to ``True``, use the default
labels ``["W", "E", "S", "N"]``.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
star is plotted instead of the north label. If set to ``True``, use the default
labels ``["W", "E", "S", "N"]``.
star is plotted instead of the north label. If set to ``True``, the default
labels ``["W", "E", "S", "N"]`` are used.

**declination**. To bypass the label, set to ``"-"``.
intervals
Specify the annotation and tick intervals for the geographic and magnetic
directions. It can be a seqeunce of three or six values. If three values are
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
directions. It can be a seqeunce of three or six values. If three values are
directions. It can be a sequence of three or six values. If three values are

@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.

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.

3 participants