View source: R/geom_textdensity.R
geom_textdensity | R Documentation |
Line plots of smoothed kernel density estimates are available
in ggplot2 via geom_density
. This geom
layer simply adds a text label to each curve that follow the contour of
the density line when used as a drop-in replacement for
geom_density
geom_textdensity(
mapping = NULL,
data = NULL,
stat = "density",
position = "identity",
...,
bw = "nrd0",
adjust = 1,
kernel = "gaussian",
n = 512,
lineend = "butt",
linejoin = "round",
linemitre = 10,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_labeldensity(
mapping = NULL,
data = NULL,
stat = "density",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...,
lineend = "butt",
linejoin = "round",
linemitre = 10,
bw = "nrd0",
adjust = 1,
kernel = "gaussian",
n = 512,
label.padding = unit(0.25, "lines"),
label.r = unit(0.15, "lines"),
arrow = NULL
)
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
|
bw |
The smoothing bandwidth to be used.
If numeric, the standard deviation of the smoothing kernel.
If character, a rule to choose the bandwidth, as listed in
|
adjust |
A multiplicate bandwidth adjustment. This makes it possible
to adjust the bandwidth while still using the a bandwidth estimator.
For example, |
kernel |
Kernel. See list of available kernels in |
n |
number of equally spaced points at which the density is to be
estimated, should be a power of two, see |
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
linemitre |
Line mitre limit (number greater than 1). |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
label.padding |
Amount of padding around label. Defaults to 0.25 lines. |
label.r |
Radius of rounded corners. Defaults to 0.15 lines. |
arrow |
Arrow specification, as created by |
A Layer
ggproto object that can be added to a plot.
geom_textdensity()
understands the following aesthetics (required aesthetics are in bold):
x
label
alpha
angle
colour
family
fontface
group
hjust
linecolour
lineheight
linetype
linewidth
size
spacing
textcolour
vjust
In addition to aforementioned aesthetics, geom_labeldensity()
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")
.
Other geom layers that place text on paths.
ggplot(iris, aes(Sepal.Length, label = Species, color = Species)) +
geom_textdensity()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.