In [1]:
%useLatestDescriptors
%use lets-plot
In [2]:
import org.jetbrains.letsPlot.intern.Plot
import org.jetbrains.letsPlot.intern.Feature
In [3]:
fun docsDarkTheme(): Feature {
val bgColor = "#19191c"
return theme(
plotBackground = elementRect(fill = bgColor),
geom = elementGeom(pen = "white", paper = bgColor)
) + flavorHighContrastDark()
}
In [4]:
fun getData(): Map<String, List<*>> {
val n = 26
return mapOf(
"x" to (0..3).flatMap {
(0..6).toList()
}.take(n),
"y" to (List(7) { 3 } + List(7) { 2 } + List(7) { 1 } + List(7) { 0 }).take(n),
"shape" to (0 until n).toList(),
)
}
In [5]:
fun getPlot(): Plot {
return letsPlot(getData()) { x = "x"; y = "y" } +
scaleShapeIdentity() +
geomText(size = 15, family = "mono", position = positionNudge(y = .3)) { label = "shape" } +
geomPoint(size = 10, fill = "#fa9fb5", tooltips = tooltipsNone) { shape = "shape" } +
coordCartesian(xlim = Pair(-0.5, 6.5), ylim = Pair(-0.25, 3.5)) +
ggsize(800, 600) +
themeVoid()
}
In [6]:
val plot = getPlot()
ggsave(plot, "aesthetics_shape.png")
plot
Out[6]:
In [7]:
val plotDark = getPlot() + docsDarkTheme()
ggsave(plotDark, "aesthetics_shape_dark.png")
plotDark
Out[7]: