r - 在 Jetbrains 的 Lets-Plot 中添加字幕、标题和图例标题
问题描述
我使用https://github.com/JetBrains/lets-plot库在 Kotlin 中编写了一个绘图。我希望能够设置标题、副标题、标题,并编辑(或删除)图例标题。
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()
在 ggplot2 中,我可以在或中设置字幕labs()
,但在 Lets-plot 中,这些函数既不接受字幕也不接受字幕。ggtitle()
theme()
有没有办法设置副标题、标题以及编辑或删除图例标题?
解决方案
推荐阅读
- javascript - 获取与按钮相同的列表项中的文本
- javafx - 设置 TableView 单元格的背景颜色
- asp.net-core - Html.BeginForm 使用 Html.HiddenFor 将空对象发送到控制器
- c# - 创建 EF Core Include().ThenInclude() 之类的函数?
- design-patterns - 更改恢复实施
- python - 尽管空堆栈测试,递归函数不起作用
- oracle - 是否可以交换 oracle 12c PDB
- django - 在 django 生产中无法导出静态
- angular - 如何在点击时刷新页面(离子 v4)
- css - 如何定位在 div 背景图像后面?