Add the Frame/Axis class for setting frame and axes [Part 1]#4406
Add the Frame/Axis class for setting frame and axes [Part 1]#4406
Conversation
| >>> fig.basemap( | ||
| ... region=[0, 10, 0, 20], | ||
| ... projection="X10c/10c", | ||
| ... frame=Axis(annot=4, tick=2, grid=1), |
There was a problem hiding this comment.
The "long" version would be
frame=Frame(axis=Axis(annot=4, tick=2, grid=1))
?
weiji14
left a comment
There was a problem hiding this comment.
Nice and focused start, just some comments for now.
| 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"), |
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?
There was a problem hiding this comment.
I plan to alias it to hlabel. See #4016 for the proposed full aliases.
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
|
@GenericMappingTools/pygmt-maintainers I plan to merge this PR tomorrow, so please give this PR a final review. |
pygmt/params/frame.py
Outdated
|
|
||
| Examples | ||
| -------- | ||
| To specify the same attributes for all axes, with intervals of 4 for annotations, |
There was a problem hiding this comment.
Wondering, if all four sides (WSEN) or only the west/left and south/bottom sides (WSrt) have annotations and ticks.
There was a problem hiding this comment.
Axis controls annotation/tick/gridline settings for x- and y-axes, while WSEN/WSrt further controls if a specific axis need annotation/tick/grdiline. I've rephrase the docstring and hopefully can make it clear.
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
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: