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.
The text color can be manually specified using: `theme(labelText=elementText(color=...))`
Alternatively, the `inheritColor()`
method can be used to override both automatic and manual color settings, making the annotation text use the geometry's `color`
aesthetic instead.
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.