Skip to content

Figure.subplot: Add parameters tag/tag_box/tag_position/tag_orientation/tag_number_style/tag_font for controlling subplot tagging#4313

Merged
seisman merged 27 commits into
mainfrom
subplot/A
Feb 9, 2026
Merged

Figure.subplot: Add parameters tag/tag_box/tag_position/tag_orientation/tag_number_style/tag_font for controlling subplot tagging#4313
seisman merged 27 commits into
mainfrom
subplot/A

Conversation

@seisman
Copy link
Copy Markdown
Member

@seisman seisman commented Dec 20, 2025

This PR provides a more Pythonic implementation for the -A option of subplot by splitting it into multiple parameters.

The full syntax is:

-A[autotag][+cdx[/dy]][+gfill][+j|Jrefpoint][+odx[/dy]][+ppen][+r|R][+s[[dx/dy][/shade]]][+v]

In PyGMT, the Pythonic parameters are:

  • autotag: autotag [Previously it's called autolabel, but I feel it should be called autotag or tag]
  • [+cdx[/dy]][+gfill][+ppen][+s[[dx/dy][/shade]]]: tag_box. Controls the box outline. It's a subset of the existing Box class, so we can directly pass a Box object!
  • [+j|Jrefpoint][+odx[/dy]]: tag_position, use the Position class
  • +r|R: tag_number_style
  • +v: tag_orientation
  • FONT_TAG: tag_font

It's a POC PR, and is not complete or final yet. Here is an example usage:

import pygmt
from pygmt.params import Box

fig = pygmt.Figure()
with fig.subplot(
    nrows=2, ncols=2, subsize=(5, 5), 
    autotag="(1)", 
    tag_box=Box(pen="1p,red", fill="lightblue"), 
    tag_position="TL", 
    tag_orientation="vertical",
    tag_number_style="roman",
    tag_font="12p,blue"
):
    for i in range(4):
        fig.basemap(region=[0, 10, 0, 10], projection="X?", panel=True)
fig.show()

Preview: https://pygmt-dev--4313.org.readthedocs.build/en/4313/api/generated/pygmt.Figure.subplot.html#pygmt.Figure.subplot

@seisman seisman added the enhancement Improving an existing feature label Dec 20, 2025
@seisman seisman added this to the 0.19.0 milestone Jan 18, 2026
@seisman seisman force-pushed the subplot/A branch 2 times, most recently from 4b6a925 to c95883c Compare January 19, 2026 07:16
@seisman seisman changed the title POC: Figure.subplot: Pythonic implemention for the subplot tagging Figure.subplot: Add parameters autotag/tag_box/tag_position/tag_orientation/tag_number_style/tag font for controlling subplot tagging Jan 31, 2026
@seisman seisman added the needs review This PR has higher priority and needs review. label Jan 31, 2026
@seisman seisman marked this pull request as ready for review February 5, 2026 04:02
@seisman
Copy link
Copy Markdown
Member Author

seisman commented Feb 5, 2026

@GenericMappingTools/pygmt-maintainers I think this PR is ready for final reviews. Please read the top post for the implementation details.

I'm still debating about the parameter name autotag. Previously, the -A option was aliased to autolabel. This PR splits it into multiple parameters autotag/tag_box/tag_position/tag_number_style/tag_orientation/tag_font. Following our naming conventions, autotag should be auto_tag, but I'm debating if we should just call it tag, and also rename Figure.set_panel's fixedlabel parameter to tag, too. I feel tag makes the parameters more consistent:

The new syntax would be like:

with fig.subplot(nrows=2, ncols=2, tag="(a)"):
    with fig.set_panel(tag="AnyTag"):
        ...

So, tag="(a)" in Figure.subplot sets the tag for the first subplot, and other subplots are automatically tagged, while tag="AnyTag" sets the tag for a specified panel.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 5, 2026

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

Status Path
renamed pygmt/tests/baseline/test_subplot_autolabel_margins_title.png -> pygmt/tests/baseline/test_subplot_autotag_margins_title.png

Image diff(s)

Details

Added images

Modified images

Path Old New

Report last updated at commit 0c7de28

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 5, 2026

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

Status Path
renamed pygmt/tests/baseline/test_subplot_autolabel_margins_title.png -> pygmt/tests/baseline/test_subplot_tag_margins_title.png

Image diff(s)

Details

Added images

Modified images

Path Old New

Report last updated at commit b24ca35

@seisman seisman changed the title Figure.subplot: Add parameters autotag/tag_box/tag_position/tag_orientation/tag_number_style/tag font for controlling subplot tagging Figure.subplot: Add parameters autotag/tag_box/tag_position/tag_orientation/tag_number_style/tag_font for controlling subplot tagging Feb 6, 2026
@yvonnefroehlich
Copy link
Copy Markdown
Member

I'm still debating about the parameter name autotag. Previously, the -A option was aliased to autolabel. This PR splits it into multiple parameters autotag/tag_box/tag_position/tag_number_style/tag_orientation/tag_font. Following our naming conventions, autotag should be auto_tag, but I'm debating if we should just call it tag, and also rename Figure.set_panel's fixedlabel parameter to tag, too. I feel tag makes the parameters more consistent:

The new syntax would be like:

with fig.subplot(nrows=2, ncols=2, tag="(a)"):
    with fig.set_panel(tag="AnyTag"):
        ...

So, tag="(a)" in Figure.subplot sets the tag for the first subplot, and other subplots are automatically tagged, while tag="AnyTag" sets the tag for a specified panel.

I like the consistency, and tag is shorter compared to the current names.

Comment thread pygmt/src/subplot.py Outdated
@seisman
Copy link
Copy Markdown
Member Author

seisman commented Feb 7, 2026

I'm still debating about the parameter name autotag. Previously, the -A option was aliased to autolabel. This PR splits it into multiple parameters autotag/tag_box/tag_position/tag_number_style/tag_orientation/tag_font. Following our naming conventions, autotag should be auto_tag, but I'm debating if we should just call it tag, and also rename Figure.set_panel's fixedlabel parameter to tag, too. I feel tag makes the parameters more consistent:
The new syntax would be like:

with fig.subplot(nrows=2, ncols=2, tag="(a)"):
    with fig.set_panel(tag="AnyTag"):
        ...

So, tag="(a)" in Figure.subplot sets the tag for the first subplot, and other subplots are automatically tagged, while tag="AnyTag" sets the tag for a specified panel.

I like the consistency, and tag is shorter compared to the current names.

I've renamed autotag to tag, and will rename fixedlabel to tag in a separate PR (so that we can have an entry in the changelog.

@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Feb 7, 2026
@yvonnefroehlich yvonnefroehlich added the deprecation Deprecating a feature label Feb 7, 2026
@seisman seisman changed the title Figure.subplot: Add parameters autotag/tag_box/tag_position/tag_orientation/tag_number_style/tag_font for controlling subplot tagging Figure.subplot: Add parameters tag/tag_box/tag_position/tag_orientation/tag_number_style/tag_font for controlling subplot tagging Feb 8, 2026
@seisman
Copy link
Copy Markdown
Member Author

seisman commented Feb 8, 2026

I plan to merge this PR in 24 hours if no further comments.

@seisman seisman merged commit 83f06c3 into main Feb 9, 2026
21 of 24 checks passed
@seisman seisman deleted the subplot/A branch February 9, 2026 14:38
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Feb 9, 2026
@seisman seisman removed the deprecation Deprecating a feature label Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants