Skip to content

Conversation

@Chuan1937
Copy link
Contributor

@Chuan1937 Chuan1937 commented Jan 14, 2026

Track the current region at the PyGMT level, instead of relying on the GMT_Extract_Region function of GMT.

Fix method:

1.added the _current_region attribute to the Figure class to track the current region.
2.modified the region attribute to prioritize returning the tracked region, and if not set, revert to GMT extraction.
3.updated the current region in the basemap and coast methods.
4.added the _update_current_region method to handle region transformations.

Fixes #3764

Copilot AI review requested due to automatic review settings January 14, 2026 08:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses issue #3764 by implementing region tracking at the PyGMT level instead of relying on GMT's GMT_Extract_Region function. The implementation adds a _current_region attribute to the Figure class and updates it when plotting functions are called with an explicit region parameter.

Changes:

  • Added _current_region instance variable to track region at the PyGMT level
  • Implemented _update_current_region() method in Figure class to update region tracking
  • Added region tracking calls in basemap() and coast() functions

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
pygmt/figure.py Added _current_region attribute, _update_current_region() method, and fallback logic in region property
pygmt/src/basemap.py Added call to _update_current_region() to track regions set via basemap
pygmt/src/coast.py Added call to _update_current_region() to track regions set via coast

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Chuan1937 Chuan1937 changed the title Track the current region at the PyGMT level, instead of relying on th… Fix "fig.region" is not updated to the "region" of the current plot Jan 14, 2026
@seisman
Copy link
Member

seisman commented Jan 14, 2026

Not sure if this is the best way to address the issue. We need more brainstorming on potential solutions.

@seisman seisman marked this pull request as draft January 14, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"fig.region" is not updated to the "region" of the current plot | Wrong lines via hlines and vlines

2 participants