-
Notifications
You must be signed in to change notification settings - Fork 235
Fix "fig.region" is not updated to the "region" of the current plot #4356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…e GMT_Extract_Region function of GMT.
There was a problem hiding this 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_regioninstance 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()andcoast()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.
|
Not sure if this is the best way to address the issue. We need more brainstorming on potential solutions. |
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_regionattribute to theFigureclass to track the current region.2.modified the
regionattribute to prioritize returning the tracked region, and if not set, revert to GMT extraction.3.updated the current region in the
basemapandcoastmethods.4.added the
_update_current_regionmethod to handle region transformations.Fixes #3764