layer Labels
Configure annotations for geometry layers.
Annotations are currently supported for bar, pie, and crossbar geometry layers. This class provides methods to customize the appearance and content of text labels displayed on these geometries.
Notes
By default, annotation text color is automatically selected for optimal contrast: white text appears on darker filled geometries, and black text appears on lighter filled geometries.
Use theme(labelText = elementText(color = ...)) to customize the appearance of annotation text. See also elementText().
Alternatively, the inheritColor() method can be used to make annotation text use the geometry's color aesthetic, overriding both the automatically selected text color and any color specified via theme(labelText = elementText(color = ...)).
Examples
val data = mapOf("name" to listOf("a", "b", "c", "d", "b"), "value" to listOf(40, 90, 10, 50, 20))
letsPlot(data) +
geomPie(
size = 15, hole = 0.2,
labels = layerLabels("..proppct..").format("..proppct..", "{.1f}%").size(15)
) { fill = asDiscrete("name", orderBy = "..count.."); weight = "value" }Parameters
Variable names to place in the annotation with default formatting. Useful for specifying the annotation content quickly, instead of configuring it via the line() method.
Functions
Defines the format for displaying the value. The format will be applied to the corresponding value specified in the line template.
Use the layer's color for the annotation text.
Specifies the string template to use in the annotation.
Specifies a text size in the annotation.