Skip to content

Conversation

@seisman
Copy link
Member

@seisman seisman commented Jul 29, 2025

Description of proposed changes

This PR adds the Figure.directional_rose method to plot a map directional rose on map. It wraps the basemap -Td/coast -Td options.

  • [g|j|J|n|x]<refpoint>[+j<justify>][+o<dx>[/<dy>]]: position
  • +w<width>: width
  • +f[<level>]: fancy
  • +l<w,e,s,n>]: labels

Example

import pygmt
from pygmt.params import Position
fig = pygmt.Figure()
fig.basemap(region=[0, 80, -30, 30], projection="M10c", frame=True)
fig.directional_rose(width="3c")
fig.show()

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

Addressing #2831. Related to #4010. Related to #4164.

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

@seisman seisman added the feature Brand new feature label Jul 29, 2025
@seisman seisman force-pushed the feature/direction_rose branch 2 times, most recently from a46dc2c to 59f2b18 Compare July 29, 2025 08:38
@seisman seisman changed the title Add Figure.directional_rose to plot a directional rose on map WIP: Add Figure.directional_rose to plot a directional rose on map Jul 30, 2025
@seisman seisman added this to the 0.17.0 milestone Aug 24, 2025
@seisman seisman changed the title WIP: Add Figure.directional_rose to plot a directional rose on map Add Figure.directional_rose to plot a directional rose on map Sep 6, 2025
@seisman seisman force-pushed the feature/direction_rose branch from 2cc02fb to 4b7b799 Compare September 8, 2025 06:45
@weiji14 weiji14 modified the milestones: 0.17.0, 0.18.0 Sep 17, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 15, 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_directional_rose.png
added pygmt/tests/baseline/test_directional_rose_complex.png
added pygmt/tests/baseline/test_directional_rose_fancy.png

Image diff(s)

Details

Added images

  • test_directional_rose.png

  • test_directional_rose_complex.png

  • test_directional_rose_fancy.png

Modified images

Path Old New

Report last updated at commit 7ba2bda

@seisman seisman marked this pull request as ready for review October 15, 2025 02:36
@seisman seisman added needs review This PR has higher priority and needs review. and removed needs review This PR has higher priority and needs review. labels Oct 15, 2025
@seisman seisman force-pushed the feature/direction_rose branch from 8078a84 to 1a8ea29 Compare December 15, 2025 07:11
@seisman seisman added the needs review This PR has higher priority and needs review. label Dec 15, 2025
@seisman seisman force-pushed the feature/direction_rose branch from 1a8ea29 to f2f22c3 Compare December 15, 2025 07:25
Copy link
Member

@michaelgrund michaelgrund left a comment

Choose a reason for hiding this comment

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

Looks good!

@seisman seisman force-pushed the feature/direction_rose branch 4 times, most recently from 6ab446b to 247ec6d Compare December 18, 2025 11:58
@seisman seisman force-pushed the feature/direction_rose branch 2 times, most recently from 0851a2e to 173dd95 Compare December 19, 2025 04:00
@seisman seisman force-pushed the feature/direction_rose branch from 173dd95 to 7ba2bda Compare December 19, 2025 04:15
@seisman
Copy link
Member Author

seisman commented Dec 19, 2025

I think this feature is also ready for review. The key point that we need to reach an agreement on is the default position.

As shown below, GMT defaults to plot directional roses at x0/0, but there are some issues (potential bugs):

  • It seems the anchor point is "BL" for a simple rose and "MC" for a fancy rose. So, the behavior is inconsistent.
  • The box is not drawn for the simple rose when position is x0/0
  • Setting position to jBL looks good, but the box for the simple rose seems to be a square which doesn't fit the simple rose well.

I'll file an upstream issue report later (GenericMappingTools/gmt#8841), but I feel in PyGMT, we should let the default position to jBL (which seems to have offsets automatically).

gmt begin map png
	gmt basemap -R100/110/30/35 -JM10c -Baf
	gmt basemap -Td+w2c -F+pblue
	gmt basemap -Td+w2c+f -F+pred

	gmt basemap -R100/110/30/35 -JM10c -Baf -Xw+2c
	gmt basemap -Tdx0/0+w2c -F+pblue
	gmt basemap -Tdx0/0+w2c+f -F+pred

	gmt basemap -R100/110/30/35 -JM10c -Baf -Xw+2c
	gmt basemap -TdjBL+w2c -F+pblue
	gmt basemap -TdjBL+w2c+f -F+pred
gmt end show
map

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.

5 participants