Use the labelText
parameter in theme()
to set basic text settings for annotations, using the elementText()
function with the following parameters:
layerLabels().size()
;%useLatestDescriptors
%use dataframe
%use lets-plot
LetsPlot.getInfo()
Lets-Plot Kotlin API v.4.9.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.5.1.
val mpg = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
mpg.head(3)
DataFrame: rowsCount = 3, columnsCount = 12
untitled | manufacturer | model | displ | year | cyl | trans | drv | cty | hwy | fl | class |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | audi | a4 | 1.800000 | 1999 | 4 | auto(l5) | f | 18 | 29 | p | compact |
2 | audi | a4 | 1.800000 | 1999 | 4 | manual(m5) | f | 21 | 29 | p | compact |
3 | audi | a4 | 2.000000 | 2008 | 4 | manual(m6) | f | 20 | 31 | p | compact |
val labelTextOpts = elementText(family = "Rockwell", face = "bold", size = 16, color = "#542788")
letsPlot(mpg.toMap()) +
geomBar(labels = layerLabels().line("@..sumpct..")) { x = "class"; fill = "class" } +
theme(labelText = labelTextOpts)
letsPlot(mpg.toMap()) +
geomPie(size = 26, hole = 0.3, labels = layerLabels().line("@..proppct..")) { fill = "class" } +
themeVoid() +
theme(labelText = labelTextOpts)