pathtext
Makie.pathtext Function
pathtext(path; text = "", kwargs...)Draw text along a path. path can be a Vector{<: Point2} (with optional NaN separators between sub-paths) or a BezierPath.
When a BezierPath is provided, glyphs are positioned and oriented using exact cubic-Bézier evaluation, giving smooth tangent rotations. A polyline input is sampled piecewise-linearly.
The path itself may be given in :data or :pixel space, controlled by the space attribute.
Newlines in text are currently not supported.
Plot type
The plot type alias for the pathtext function is PathText.
Examples
Along a BezierPath
using CairoMakie
bp = BezierPath([
MoveTo(Point2(0, 0)),
CurveTo(Point2(1, 3), Point2(3, 3), Point2(4, 0)),
])
f = Figure()
ax = Axis(f[1, 1], aspect = DataAspect(), limits = (nothing, (-0.5, 3)))
lines!(ax, bp, color = (:steelblue, 0.4), linewidth = 2)
pathtext!(ax, bp, text = "text along a Bezier curve", fontsize = 20, align = (:center, :bottom))
f
Along a polyline
using CairoMakie
path = Point2f[(0, 0), (1, 0), (2, 1), (3, 1), (4, 0)]
f = Figure()
ax = Axis(f[1, 1])
lines!(ax, path, color = :gray70)
pathtext!(ax, path, text = "polyline path", fontsize = 18, align = (:center, :baseline))
f
RichText with sub/superscripts
using CairoMakie
bp = BezierPath([
MoveTo(Point2(0, 0)),
CurveTo(Point2(2, 4), Point2(6, 4), Point2(8, 0)),
])
f = Figure()
ax = Axis(f[1, 1], aspect = DataAspect(), limits = (nothing, (-0.5, 4)))
lines!(ax, bp, color = (:gray, 0.4), linewidth = 2)
pathtext!(ax, bp,
text = rich("H", subscript("2"), "O → H", superscript("+"), " + OH", superscript("−")),
fontsize = 24, align = (:center, :bottom))
f
Attributes
align
Defaults to (:left, :baseline)
Alignment of the text relative to the path, as a (halign, valign) tuple. halign controls position along the path (:left, :center, :right, or a Real fraction 0–1). valign controls perpendicular placement (:baseline, :bottom, :center, :top).
using CairoMakie
bp = BezierPath([
MoveTo(Point2(0, 0)),
CurveTo(Point2(1, 3), Point2(3, 3), Point2(4, 0)),
])
fig = Figure(size = (800, 600))
for (i, va) in enumerate((:top, :center, :baseline, :bottom))
r, c = fldmod1(i, 2)
ax = Axis(fig[r, c], aspect = DataAspect(), title = "valign = $(repr(va))",
limits = (nothing, (-0.5, 3)))
lines!(ax, bp, color = (:steelblue, 0.5), linewidth = 2)
pathtext!(ax, bp, text = "Text along a path", fontsize = 22,
align = (:center, va))
end
fig
alpha
Defaults to 1.0
The alpha value of the colormap or color attribute. Multiple alphas like in plot(alpha=0.2, color=(:red, 0.5)), will get multiplied.
clip_planes
Defaults to @inherit clip_planes automatic
Clip planes offer a way to do clipping in 3D space. You can set a Vector of up to 8 Plane3f planes here, behind which plots will be clipped (i.e. become invisible). By default clip planes are inherited from the parent plot or scene. You can remove parent clip_planes by passing Plane3f[].
color
Defaults to @inherit textcolor
The color of the text. May be a single value or a vector with one entry per character.
colormap
Defaults to @inherit colormap :viridis
Sets the colormap that is sampled for numeric colors. PlotUtils.cgrad(...), Makie.Reverse(any_colormap) can be used as well, or any symbol from ColorBrewer or PlotUtils. To see all available color gradients, you can call Makie.available_gradients().
colorrange
Defaults to automatic
The values representing the start and end points of colormap.
colorscale
Defaults to identity
The color transform function. Can be any function, but only works well together with Colorbar for identity, log, log2, log10, sqrt, logit, Makie.pseudolog10, Makie.Symlog10, Makie.AsinhScale, Makie.SinhScale, Makie.LogScale, Makie.LuptonAsinhScale, and Makie.PowerScale.
depth_shift
Defaults to 0.0
Adjusts the depth value of a plot after all other transformations, i.e. in clip space, where -1 <= depth <= 1. This only applies to GLMakie and WGLMakie and can be used to adjust render order (like a tunable overdraw).
font
Defaults to @inherit font
Sets the font. Can be a Symbol that is looked up in fonts or a font path/name.
fonts
Defaults to @inherit fonts
Dictionary of fonts that can be referenced by Symbol.
fontsize
Defaults to @inherit fontsize
Font size in pixels.
fxaa
Defaults to true
Adjusts whether the plot is rendered with fxaa (fast approximate anti-aliasing, GLMakie only). Note that some plots implement a better native anti-aliasing solution (scatter, text, lines). For them fxaa = true generally lowers quality. Plots that show smoothly interpolated data (e.g. image, surface) may also degrade in quality as fxaa = true can cause blurring.
highclip
Defaults to automatic
The color for any value above the colorrange.
inspectable
Defaults to @inherit inspectable
Sets whether this plot should be seen by DataInspector. The default depends on the theme of the parent scene.
inspector_clear
Defaults to automatic
Sets a callback function (inspector, plot) -> ... for cleaning up custom indicators in DataInspector.
inspector_hover
Defaults to automatic
Sets a callback function (inspector, plot, index) -> ... which replaces the default show_data methods.
inspector_label
Defaults to automatic
Sets a callback function (plot, index, position) -> string which replaces the default label generated by DataInspector.
lowclip
Defaults to automatic
The color for any value below the colorrange.
model
Defaults to automatic
Sets a model matrix for the plot. This overrides adjustments made with translate!, rotate! and scale!.
nan_color
Defaults to :transparent
The color for NaN values.
offset
Defaults to 0.0
Additional perpendicular offset (in pixels) from the path, applied on top of valign. Positive values shift the text to the left of the path's direction of travel.
using CairoMakie
bp = BezierPath([
MoveTo(Point2(0, 0)),
CurveTo(Point2(1, 3), Point2(3, 3), Point2(4, 0)),
])
fig = Figure()
ax = Axis(fig[1, 1], aspect = DataAspect(), limits = (nothing, (-0.5, 3)))
lines!(ax, bp, color = (:gray, 0.4), linewidth = 2)
for (off, col) in zip((-15, 0, 15), (:red, :black, :blue))
pathtext!(ax, bp, text = "offset = $off", fontsize = 14,
align = (:center, :baseline), offset = off, color = col)
end
fig
overdraw
Defaults to false
Controls if the plot will draw over other plots. This specifically means ignoring depth checks in GL backends
space
Defaults to :data
Sets the transformation space for box encompassing the plot. See Makie.spaces() for possible inputs.
ssao
Defaults to false
Adjusts whether the plot is rendered with ssao (screen space ambient occlusion). Note that this only makes sense in 3D plots and is only applicable with fxaa = true.
strokecolor
Defaults to :black
Color of the text stroke. May be per-character.
strokewidth
Defaults to 0
Width of the text stroke in pixels. May be per-character.
text
Defaults to ""
The text to place along the path. May be String or RichText. Must not contain newlines.
using CairoMakie
bp = BezierPath([
MoveTo(Point2(0, 0)),
CurveTo(Point2(1, 2), Point2(3, 2), Point2(4, 0)),
])
fig = Figure()
ax = Axis(fig[1, 1], aspect = DataAspect())
lines!(ax, bp, color = (:gray, 0.4))
pathtext!(ax, bp, text = "plain string", fontsize = 20, align = (:left, :bottom))
pathtext!(ax, bp, text = rich("Rich", rich("Text"; color = :red, font = :bold)),
fontsize = 20, align = (:right, :bottom))
fig
transformation
Defaults to :automatic
Controls the inheritance or directly sets the transformations of a plot. Transformations include the transform function and model matrix as generated by translate!(...), scale!(...) and rotate!(...). They can be set directly by passing a Transformation() object or inherited from the parent plot or scene. Inheritance options include:
:automatic: Inherit transformations if the parent and childspaceis compatible:inherit: Inherit transformations:inherit_model: Inherit only model transformations:inherit_transform_func: Inherit only the transform function:nothing: Inherit neither, fully disconnecting the child's transformations from the parent
Another option is to pass arguments to the transform!() function which then get applied to the plot. For example transformation = (:xz, 1.0) which rotates the xy plane to the xz plane and translates by 1.0. For this inheritance defaults to :automatic but can also be set through e.g. (:nothing, (:xz, 1.0)).
transparency
Defaults to false
Adjusts how the plot deals with transparency. In GLMakie transparency = true results in using Order Independent Transparency.
visible
Defaults to true
Controls whether the plot gets rendered or not.