Skip to content

Figure.text: Allow passing a sequence of offset to the 'offset' parameter#4652

Open
seisman wants to merge 3 commits into
mainfrom
text/offset
Open

Figure.text: Allow passing a sequence of offset to the 'offset' parameter#4652
seisman wants to merge 3 commits into
mainfrom
text/offset

Conversation

@seisman
Copy link
Copy Markdown
Member

@seisman seisman commented May 22, 2026

Passing a sequence of offsets to Figure.text is frequently used but not supported yet.

This PR supports it and also migrates offset to the new alias system.

@seisman seisman added this to the 0.19.0 milestone May 22, 2026
@seisman seisman added enhancement Improving an existing feature needs review This PR has higher priority and needs review. labels May 22, 2026
Comment thread examples/gallery/images/cross_section.py Outdated
@seisman seisman requested a review from a team May 25, 2026 15:17
@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 May 25, 2026
y=[latA, latB],
text=["A", "B"],
offset="0c/0.3c", # Move text 0.2 centimeters up (y-direction)
offset=(0, 0.3), # Move text 0.3 centimeters up (y-direction)
Copy link
Copy Markdown
Member

@weiji14 weiji14 May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep the "c" unit specifier? The gmt.conf docs say:

It is recommended that users specify the units for distances and lengths by appending c (cm), i (inch), or p (points) when changing parameters using any of these methods. By default, when no unit is specified the value will be assumed to be cm for parameters not related to fonts or pen thicknesses and will be assumed to be points for parameters related to fonts or pen thicknesses.

So recommended is to append the unit, but no unit means centimeter in some but not all cases (I guess offset counts as non-font/pen thickness?). Maybe keep it as ("0c", "0.3c") to be clearer?

Copy link
Copy Markdown
Member Author

@seisman seisman May 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, appending the unit specifier is recommended in the GMT CLI. However, in PyGMT, I feel it is more natural to use plain numbers for quantities such as offsets, widths, and sizes. They are much shorter to type and can also be used directly in calculations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving an existing feature final review call This PR requires final review and approval from a second reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants