Text on a curveSource:
geom_labelcurve() draw text on curved lines. See
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 )
Set of aesthetic mappings created by
aes_(). If specified and
inherit.aes = TRUE(the default), it is combined with the default mapping at the top level of the plot. You must supply
mappingif there is no plot mapping.
The data to be displayed in this layer. There are three options:
NULL, the default, the data is inherited from the plot data as specified in the call to
data.frame, or other object, will override the plot data. All objects will be fortified to produce a data frame. See
fortify()for which variables will be created.
functionwill be called with a single argument, the plot data. The return value must be a
data.frame, and will be used as the layer data. A
functioncan be created from a
~ head(.x, 10)).
The statistical transformation to use on the data for this layer, as a string.
Position adjustment, either as a string, or the result of a call to a position adjustment function.
Other arguments passed on to
layer. These are often aesthetics, used to set an aesthetic to a fixed value, like
colour = "red"or
size = 3. These can also be the following text-path parameters:
TRUE, breaks the path into two sections with a gap on either side of the label. If
FALSE, the path is plotted as a whole. Alternatively, if
NA, the path will be broken if the string has a
vjustbetween 0 and 1, and not otherwise. The default for the label variant is
FALSEand for the text variant is
TRUE(default), inverts any text where the majority of letters would upside down along the path, to improve legibility. If
FALSE, the path decides the orientation of text.
character(1)describing how multi-line text should be justified. Can either be
unitobject of length 1 to determine the offset of the text from the path. If this is
vjustparameter decides the offset. If not
offsetargument overrules the
TRUE, will coerce the labels into expressions, allowing for plotmath syntax to be used.
TRUE, keeps the letters of a label on a straight baseline and if
FALSE(default), lets individual letters follow the curve. This might be helpful for noisy paths.
unitobject of length 1 to determine the padding between the text and the path when the
gapparameter trims the path.
logical(1)whether to interpret the text as html/markdown formatted rich text. Default:
FALSE. See also the rich text section of the details in
if TRUE, labels that are longer than their associated path will be removed.
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.
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.
The number of control points used to draw the curve. More control points creates a smoother curve.
Arrow specification, as created by
Line end style (round, butt, square).
FALSE, the default, missing values are removed with a warning. If
TRUE, missing values are silently removed.
logical. Should this layer be included in the legends?
NA, the default, includes if any aesthetics are mapped.
FALSEnever includes, and
TRUEalways includes. It can also be a named logical vector to finely select the aesthetics to display.
FALSE, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g.
Radius of rounded corners. Defaults to 0.15 lines.
Amount of padding around label. Defaults to 0.25 lines.
geom_textcurve() understands the following aesthetics (required aesthetics are in bold):
In addition to aforementioned aesthetics,
geom_labelcurve() also understands:
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
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))