Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d968a72
feat: add `pathtext` recipe for text along a path
jkrumbiegel Apr 14, 2026
04ca0a2
feat(pathtext): native BezierPath evaluation
jkrumbiegel Apr 14, 2026
60da489
feat(pathtext): support RichText input
jkrumbiegel Apr 14, 2026
3fed2a3
fix(pathtext): apply y-offset for sub/superscript in RichText
jkrumbiegel Apr 14, 2026
65e9713
fix(pathtext): normalize RichText y-offsets relative to baseline
jkrumbiegel Apr 14, 2026
d2d244f
feat(pathtext): align as (halign, valign) tuple, matching text conven…
jkrumbiegel Apr 14, 2026
27c0059
fix(pathtext): use chord rotation instead of tangent at origin
jkrumbiegel Apr 14, 2026
ec1da18
docs(pathtext): add reference page and attribute_examples
jkrumbiegel Apr 14, 2026
61d7442
docs(pathtext): credit kurbo for Bézier arc-length math
jkrumbiegel Apr 15, 2026
c62141b
test(pathtext): add reference images
jkrumbiegel Apr 15, 2026
6308e0d
fix(pathtext): avoid bridging chords across sub-path gaps
jkrumbiegel Apr 15, 2026
e64b573
test(pathtext): compact reference images
jkrumbiegel Apr 15, 2026
c9d56f7
chore(pathtext): update changelog entry with PR link
jkrumbiegel Apr 15, 2026
48fa143
feat(annotation): add Ann.Styles.WithText wrapper
jkrumbiegel Apr 15, 2026
f42a9ad
fix(pathtext test): qualify EllipticalArc to disambiguate from Delaun…
jkrumbiegel Apr 15, 2026
ff3c346
fix(pathtext): use raw strings for attribute_examples with $ interpol…
jkrumbiegel Apr 15, 2026
b07eb49
docs(annotation): replace H2O style example with simpler A→B WithText…
jkrumbiegel Apr 15, 2026
02b8c9c
refactor(pathtext): unify _pathtext_layout to a single method
jkrumbiegel Apr 15, 2026
3990793
perf/simplify(pathtext): cached cumulative arc-length and inlined tex…
jkrumbiegel Apr 15, 2026
c035836
test(annotation): add WithText example to existing annotation manual …
jkrumbiegel Apr 16, 2026
4351c55
Merge branch 'master' into jk/pathtext
jkrumbiegel Apr 16, 2026
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Added `pathtext` recipe for placing text along a path, plus `Ann.Styles.WithText` to layer path text onto any existing `annotation` style [#5596](https://github.com/MakieOrg/Makie.jl/pull/5596).
- Fixed shared precompile file path not being relocatable by using `RelocatableFolders.@path` [#5597](https://github.com/MakieOrg/Makie.jl/pull/5597)
- Added possibility to gather legend entries from multiple axes [#5551](https://github.com/MakieOrg/Makie.jl/pull/5551)
- Added complete inverse transformation support to `register_projected_positions!` with `apply_inverse_transform`, `apply_inverse_transform_func`, `apply_inverse_float32convert`, and `apply_inverse_model` kwargs. These enable correct projection from non-data spaces back to data space. Includes early-exit optimization to skip redundant transform/inverse pairs when `input_space === output_space`. [#5485](https://github.com/MakieOrg/Makie.jl/pull/5485)
Expand Down
1 change: 1 addition & 0 deletions Makie/src/Makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ include("makielayout/MakieLayout.jl")
include("figureplotting.jl")
include("basic_recipes/series.jl")
include("basic_recipes/text.jl")
include("basic_recipes/pathtext.jl")
include("basic_recipes/raincloud.jl")
include("deprecated.jl")

Expand Down
58 changes: 58 additions & 0 deletions Makie/src/basic_recipes/annotation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ baremodule Ann # bare for cleanest tab-completion behavior
using Base

using ..Arrows: Arrows
using ...Makie: Makie

struct Line end

Expand All @@ -47,6 +48,32 @@ baremodule Ann # bare for cleanest tab-completion behavior
tail = nothing
end

"""
Ann.Styles.WithText(style; text, ...)

Wraps another annotation `style` and additionally draws `text` along the
connection path using `pathtext`. The inner `style` is rendered first,
then the text is layered on top so it follows the same curve.
"""
struct WithText
style::Any
text::Any
fontsize::Float64
align::Any
offset::Float64
color::Any
end
function WithText(
style;
text = "",
fontsize = 12.0,
align = (:center, :bottom),
offset = 4.0,
color = Makie.automatic,
)
return WithText(style, text, Float64(fontsize), align, Float64(offset), color)
end

end
end

Expand Down Expand Up @@ -1023,6 +1050,20 @@ function annotation_style_plotspecs(::Ann.Styles.Line, path::BezierPath, p1, p2;
]
end

function annotation_style_plotspecs(s::Ann.Styles.WithText, path::BezierPath, p1, p2; color, linewidth)
specs = annotation_style_plotspecs(s.style, path, p1, p2; color, linewidth)
textcolor = s.color === automatic ? color : s.color
push!(
specs,
PlotSpec(
:PathText, path;
text = s.text, fontsize = s.fontsize, align = s.align,
offset = s.offset, color = textcolor, space = :pixel,
),
)
return specs
end

_auto(x::Automatic, default) = default
_auto(x, default) = x

Expand Down Expand Up @@ -1087,6 +1128,23 @@ function attribute_examples(::Type{Annotation})
fig
"""
),
Example(
code = raw"""
fig = Figure()
ax = Axis(fig[1, 1])
A, B = Point2f(1, 2), Point2f(5, 5)
scatter!(ax, [A, B], markersize = 10, color = :black)
text!(ax, [A, B], text = ["A", "B"],
align = (:right, :top), offset = (-6, -4))
annotation!(ax, [A], [B];
text = [""],
path = Ann.Paths.Arc(height = 0.4),
style = Ann.Styles.WithText(Ann.Styles.LineArrow();
text = "from A to B", fontsize = 14),
color = :steelblue, labelspace = :data, shrink = (5.0, 5.0))
fig
"""
),
],
:path => [
Example(
Expand Down
Loading
Loading