Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions pygmt/src/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
@use_alias(
C="clearance",
D="offset",
G="fill",
W="pen",
a="aspatial",
e="find",
f="coltypes",
Expand All @@ -41,8 +39,10 @@ def text_( # noqa: PLR0912, PLR0913
y=None,
position: AnchorCode | None = None,
text: str | StringArrayTypes | None = None,
angle=None,
font=None,
angle: float | Sequence[float] | bool = False,
font: str | StringArrayTypes | bool = False,
Copy link
Copy Markdown
Member

@yvonnefroehlich yvonnefroehlich Apr 11, 2026

Choose a reason for hiding this comment

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

I am wondering about the context of the type bool for angle and font. Why was there a change from None to False? And I am wondering if this causes the newly occuring warning by the Figure.text method, e.g., https://www.pygmt.org/dev/tutorials/basics/text.html:

text [WARNING]: Length <unit> e not supported - revert to default unit [point]
text [WARNING]: Fals not a valid number and may not be decoded properly.
text [WARNING]: Representation of font size not recognized. Using default.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I am wondering about the context of the type bool for angle and font. Why was there a change from None to False?

In Figure.text, angle=True, font=True means the input file contains columns for angle and font, so angle/font can accept bools.

The issue is that when changing the default from None to False, I didn't update the checking of these parameters. #4577 should fix it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In Figure.text, angle=True, font=True means the input file contains columns for angle and font, so angle/font can accept bools.

Ah, OK. Thanks!

fill: str | None = None,
pen: str | None = None,
justify: bool | None | AnchorCode | Sequence[AnchorCode] = None,
no_clip: bool = False,
projection: str | None = None,
Expand Down Expand Up @@ -74,10 +74,12 @@ def text_( # noqa: PLR0912, PLR0913
$aliases
- B = frame
- F = **+a**: angle, **+c**: position, **+j**: justify, **+f**: font
- G = fill
- J = projection
- N = no_clip
- R = region
- V = verbose
- W = pen
- c = panel
- p = perspective
- t = transparency
Expand Down Expand Up @@ -146,8 +148,11 @@ def text_( # noqa: PLR0912, PLR0913
**O** to get a rounded rectangle. In paragraph mode (*paragraph*)
you can also append lowercase **c** to get a concave rectangle or
append uppercase **C** to get a convex rectangle.
fill : str
fill
Set color for filling text boxes [Default is no fill].
pen
Set the pen used to draw a rectangle around the text string (see ``clearance``)
[Default is ``"0.25p,black,solid"``].
offset : str
[**j**\|\ **J**]\ *dx*\[/*dy*][**+v**\[*pen*]].
Offset the text from the projected (x, y) point by *dx*/\ *dy*
Expand All @@ -159,9 +164,6 @@ def text_( # noqa: PLR0912, PLR0913
Optionally, append **+v** which will draw a line from the original
point to the shifted point; append a pen to change the attributes
for this line.
pen : str
Set the pen used to draw a rectangle around the text string
(see ``clearance``) [Default is ``"0.25p,black,solid"``].
no_clip
Do **not** clip text at the frame boundaries [Default is ``False``].
$projection
Expand Down Expand Up @@ -273,7 +275,9 @@ def text_( # noqa: PLR0912, PLR0913
)

aliasdict = AliasSystem(
G=Alias(fill, name="fill"),
N=Alias(no_clip, name="no_clip"),
W=Alias(pen, name="pen"),
).add_common(
B=frame,
J=projection,
Expand Down
Loading