Fix "fig.region" is not updated to the "region" of the current plot#4356
Draft
Chuan1937 wants to merge 6 commits intoGenericMappingTools:mainfrom
Draft
Fix "fig.region" is not updated to the "region" of the current plot#4356Chuan1937 wants to merge 6 commits intoGenericMappingTools:mainfrom
Chuan1937 wants to merge 6 commits intoGenericMappingTools:mainfrom
Conversation
…e GMT_Extract_Region function of GMT.
Contributor
There was a problem hiding this comment.
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.
Member
|
Not sure if this is the best way to address the issue. We need more brainstorming on potential solutions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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