Skip to content

Commit 0643dc4

Browse files
jkrumbiegelclaude
andauthored
fix(annotation): Show lines/arrows when text is blank (#5560)
The compute graph refactor in #5448 dropped the `isfinite_rect` guard that handled empty text bounding boxes. `Rect3d()` (the default for empty strings) has Inf/-Inf origin/widths, causing `startpoint()` to return NaN and making all annotation geometry invisible. Closes #5557 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a331267 commit 0643dc4

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fixed `annotation` not showing lines/arrows when `text` is blank [#5560](https://github.com/MakieOrg/Makie.jl/pull/5560)
6+
57
## [0.24.9] - 2026-03-04
68

79
- Added loading spinner in WGLMakie that displays while the plot is being loaded [#5469](https://github.com/MakieOrg/Makie.jl/pull/5469)

Makie/src/basic_recipes/annotation.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,10 @@ function plot!(p::Annotation)
230230
)
231231

232232
# still without offset
233+
# Empty strings produce non-finite Rect3d() bounding boxes, replace with zero-size rects
234+
_guard_nonfinite(bb) = isfinite_rect(bb) ? bb : Rect2d(0, 0, 0, 0)
233235
map!(p, [txt.raw_string_boundingboxes, p.screenpoints_target], :text_bbs) do bboxes, px_pos
234-
return Rect2d.(bboxes) .+ px_pos
236+
return _guard_nonfinite.(Rect2d.(bboxes)) .+ px_pos
235237
end
236238

237239
register_camera_matrix!(p, :data, :pixel)

ReferenceTests/src/tests/examples2d.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,6 +2462,10 @@ end
24622462
text = "Corner", path = Ann.Paths.Corner(), labelspace = :data,
24632463
linewidth = 3, shrink = (0, 30)
24642464
)
2465+
annotation!(
2466+
ax, 0, -100, 10, sin(10),
2467+
style = Ann.Styles.LineArrow(),
2468+
)
24652469

24662470
f
24672471
end

0 commit comments

Comments
 (0)