textpathGrob {geomtextpath} | R Documentation |
Draw text on a path.
Description
This function creates (curved) text on a path.
Usage
textpathGrob(
label,
x = 0.5,
y = 0.5,
id = 1L,
just = "centre",
hjust = NULL,
vjust = NULL,
halign = "left",
angle = 0,
straight = FALSE,
rich = FALSE,
gp_text = gpar(),
gp_path = gpar(),
gp_box = gpar(),
gap = NA,
upright = TRUE,
text_smoothing = 0,
polar_params = NULL,
padding = unit(0.05, "inch"),
label.padding = unit(0.25, "lines"),
label.r = unit(0.15, "lines"),
remove_long = FALSE,
arrow = NULL,
default.units = "npc",
name = NULL,
vp = NULL,
as_label = FALSE
)
Arguments
label |
A |
x |
A |
y |
A |
id |
A |
just |
The justification of the text
relative to its (x, y) location. If there are two values, the first
value specifies horizontal justification and the second value specifies
vertical justification. Possible string values are: |
hjust |
A numeric vector specifying horizontal justification.
If specified, overrides the |
vjust |
A |
halign |
A |
angle |
a |
straight |
A |
rich |
A |
gp_text , gp_path |
An object of class |
gp_box |
(Optional) an object of class |
gap |
A |
upright |
A |
text_smoothing |
a |
polar_params |
a list consisting of an x, y, and r component that specifies the central point and radius of a circle around which single-point labels will be wrapped. |
padding |
A |
label.padding |
Amount of padding around label. Defaults to 0.25 lines. |
label.r |
Radius of rounded corners. Defaults to 0.15 lines. |
remove_long |
if TRUE, labels that are longer than their associated path will be removed. |
arrow |
Arrow specification, as created by |
default.units |
A string indicating the default units to use
if |
name |
A character identifier. |
vp |
A Grid viewport object (or NULL). |
as_label |
a |
Value
An object of class gTree
, containing grobs.
Examples
require(grid)
t <- seq(0, 2 * pi, length.out = 100)
grob <- textpathGrob(
label = c(
"Why I am making trigonometry jokes? Cos I can!",
"I was never any good at sine language."
),
x = c(t, t) / (2 * pi),
y = c(cos(t), sin(t)) * 0.25 + 0.5,
id = rep(1:2, each = length(t)),
vjust = rep(0.5, 2 * length(t)),
gp_text = gpar(lineheight = c(1.2, 1.2), fontsize = c(10, 10)),
gp_path = gpar(lty = c(1, 2))
)
grid.newpage(); grid.draw(grob)