I've written a plot in Kotlin using https://github.com/JetBrains/lets-plot library. I want to be able to set a title, a subtitle, a caption, and edit (or remove) the legend title.
val goodColors = listOf("#A1DBB2", "#69D2E7")
val badColors = listOf("#F45D4C", "#F7A541", "#FACA66", "#F45D4C", "#F7A541", "#FACA66")
val barWidth = 0.4
return letsPlot() +
labs(x = "", y = "", title = "My title") +
geomBar(stat = Stat.identity, position = Pos.stack, color = "black", width = barWidth) {
x = listOf(1.0, 1.0, 2.0, 2.0).map { it - (barWidth / 2) + barWidth }
y = listOf(16, 34, 18, 37)
fill = listOf("Good one", "Good two", "Good one", "Good two")
} +
geomBar(stat = Stat.identity, position = Pos.stack, color = "red", width = barWidth) {
x = listOf(1.0, 1.0, 1.0, 2.0, 2.0, 2.0).map { it - (barWidth / 2) }
y = listOf(71, 20, 17, 55, 11, 10)
fill = listOf("Bad one", "Bad two", "Bad Three", "Bad one", "Bad two", "Bad Three")
} +
scaleFillManual(values = goodColors + badColors) +
scaleXDiscrete(breaks = listOf(1.0, 2.0), labels = listOf("2021-01-01", "2021-02-01")) +
theme()
In ggplot2, I can set the subtitle in labs()
, ggtitle()
or theme()
, but in Lets-plot, these functions don't accept either a subtitle or a caption.
Is there a way to set a subtitle, a caption, and edit or remove the legend title?