Add the Frame/Axis class for setting frame and axes [Part 1]#4406
Open
Add the Frame/Axis class for setting frame and axes [Part 1]#4406
Conversation
24 tasks
2 tasks
| >>> fig.basemap( | ||
| ... region=[0, 10, 0, 20], | ||
| ... projection="X10c/10c", | ||
| ... frame=Axis(annot=4, tick=2, grid=1), |
Member
There was a problem hiding this comment.
The "long" version would be
frame=Frame(axis=Axis(annot=4, tick=2, grid=1))
?
weiji14
reviewed
Mar 7, 2026
Member
weiji14
left a comment
There was a problem hiding this comment.
Nice and focused start, just some comments for now.
| >>> fig.show() | ||
| """ | ||
|
|
||
| #: Specify the interval for annoations. It can be ``True`` to let GMT decide the |
Member
There was a problem hiding this comment.
Suggested change
| #: Specify the interval for annoations. It can be ``True`` to let GMT decide the | |
| #: Specify the interval for annotations. It can be ``True`` to let GMT decide the |
Comment on lines
+35
to
+40
| #: interval automatically; or a value to set a specific interval in the format of | ||
| #: *stride*\ [±\ *phase*][*unit*], where, *stride* is the interval, *phase* is the | ||
| #: offset to shift the annotations by that amount, and *unit* is one of the | ||
| #: :gmt-docs:`18 supported unit codes <reference/options.html#tbl-units>` related to | ||
| #: time intervals. | ||
| annot: float | bool = False |
Member
There was a problem hiding this comment.
Allow str type also considering phase/unit can be appended (e.g. in the case of time axes)?
Suggested change
| #: interval automatically; or a value to set a specific interval in the format of | |
| #: *stride*\ [±\ *phase*][*unit*], where, *stride* is the interval, *phase* is the | |
| #: offset to shift the annotations by that amount, and *unit* is one of the | |
| #: :gmt-docs:`18 supported unit codes <reference/options.html#tbl-units>` related to | |
| #: time intervals. | |
| annot: float | bool = False | |
| #: interval automatically; or a value to set a specific interval in the format of | |
| #: *stride*\ [±\ *phase*][*unit*], where, *stride* is the interval, *phase* is the | |
| #: offset to shift the annotations by that amount, and *unit* is one of the | |
| #: :gmt-docs:`18 supported unit codes <reference/options.html#tbl-units>` related to | |
| #: time intervals. | |
| annot: float | str | bool = False |
Comment on lines
+42
to
+46
| #: Specify the interval for ticks. Same format as ``annot``. | ||
| tick: float | bool = False | ||
|
|
||
| #: Specify the interval for gridlines. Same format as ``annot``. | ||
| grid: float | bool = False |
Member
There was a problem hiding this comment.
Suggested change
| #: Specify the interval for ticks. Same format as ``annot``. | |
| tick: float | bool = False | |
| #: Specify the interval for gridlines. Same format as ``annot``. | |
| grid: float | bool = False | |
| #: Specify the interval for ticks. Same format as ``annot``. | |
| tick: float | str | bool = False | |
| #: Specify the interval for gridlines. Same format as ``annot``. | |
| grid: float | str | bool = False |
| Alias(self.annot, name="annot", prefix="a"), | ||
| Alias(self.tick, name="tick", prefix="f"), | ||
| Alias(self.grid, name="grid", prefix="g"), | ||
| Alias(self.label, name="label", prefix="+l"), |
Member
There was a problem hiding this comment.
How to alias +L "forces a horizontal label for y-axes, which is useful for very short labels" (https://docs.generic-mapping-tools.org/6.6/gmt.html#axes-settings) later?
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.
This PR implements the
Frame/Axisclass for setting frame and axes attributes. It's a subset of PR #4016 because the-Boption is complicated, and it will take a long time to finish #4016, which again will delay the paper submission.Currently, only a small subset of the
-Boption is implemented in this PR, but it should already cover most use cases.Here is a comparison table between the GMT CLI and the PyGMT versions:
-Bframe=True-BWSENframe=Frame("WSEN")orframe=Frame(axes="WSEN")-BWSEN+tMY TITLEframe=Frame("WSEN", title="MY TITLE")-Baframe=Axis(annnot=True)-Bafgframe=Axis(annot=True, tick=True, grid=True)-Ba30f15g5frame=Axis(annot=30, tick=15, grid=5)-Ba30f15g5+lLABELframe=Axis(annot=30, tick=15, grid=5, label="LABEL")-BWSEN+tTITLE -Bxa30f15g5+lXlabel -Bya4f2g1+lYlabelframe=Frame("WSEN", title="TITLE", xaxis=Axis(annot=30, tick=15, grid=5, label="Ylabel"), yaxis=Axis(annot=4, tick=4, grid=1, label="Ylabel"))This PR doens't break backward-compatibility, so
frame="WSEN",frame="afg",frame="a30f15g5",frame=["WSEN+tTITLE", "xafg", "yafg"]are still supported.Preview: