View source: R/geom_textcurve.R
geom_textcurve | R Documentation |
geom_textcurve()
and geom_labelcurve()
draw text on curved lines. See
the underlying grid::curveGrob()
for the parameters that
control the curve.
geom_textcurve(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
curvature = 0.5,
angle = 90,
ncp = 5,
arrow = NULL,
lineend = "butt",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_labelcurve(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
curvature = 0.5,
angle = 90,
ncp = 5,
arrow = NULL,
lineend = "butt",
label.r = unit(0.15, "lines"),
label.padding = unit(0.25, "lines"),
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this
layer, either as a |
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
... |
Other arguments passed on to
|
curvature |
A numeric value giving the amount of curvature. Negative values produce left-hand curves, positive values produce right-hand curves, and zero produces a straight line. |
angle |
A numeric value between 0 and 180, giving an amount to skew the control points of the curve. Values less than 90 skew the curve towards the start point and values greater than 90 skew the curve towards the end point. |
ncp |
The number of control points used to draw the curve. More control points creates a smoother curve. |
arrow |
Arrow specification, as created by |
lineend |
Line end style (round, butt, square). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
label.r |
Radius of rounded corners. Defaults to 0.15 lines. |
label.padding |
Amount of padding around label. Defaults to 0.25 lines. |
A Layer
ggproto object that can be added to a plot.
geom_textcurve()
understands the following aesthetics (required aesthetics are in bold):
x
xend
y
yend
label
alpha
angle
colour
family
fontface
group
hjust
linecolour
lineheight
linetype
linewidth
size
spacing
textcolour
vjust
In addition to aforementioned aesthetics, geom_labelcurve()
also understands:
boxcolour
boxlinetype
boxlinewidth
fill
The spacing
aesthetic allows fine control of spacing
of text, which is called 'tracking' in typography.
The default is 0 and units are measured in 1/1000 em.
Numbers greater than zero increase the spacing,
whereas negative numbers decrease the spacing.
Learn more about setting these aesthetics
in vignette("ggplot2-specs")
.
t <- seq(0, 2 * pi, length.out = 4)[-1]
df <- data.frame(
x = cos(t),
y = sin(t),
xend = cos(t + 1.8),
yend = sin(t + 1.8)
)
ggplot(df, aes(x, y, xend = xend, yend = yend)) +
geom_textcurve(
label = c(
"A chicken lays an egg",
"A chick becomes a chicken",
"An egg hatches into a chick"
),
curvature = 0.5, vjust = 2,
arrow = arrow(ends = "first")
) +
coord_equal(xlim = c(-1.1, 1.1), ylim = c(-1.1, 1.1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.