in plot-api/src/commonMain/kotlin/org/jetbrains/letsPlot/bistro/common/Plot2dUtil.kt [164:217]
fun parseMarginalLayer(geomKind: String, side: Char, size: Any?): Feature {
val marginalColor = when {
colorBy != null -> null
color != null -> color
else -> DEF_COLOR
}
val layer = when (geomKind) {
in listOf("dens", "density") -> {
geomArea(
stat = Stat.density(),
position = positionIdentity,
color = marginalColor,
fill = marginalColor,
alpha = MARGINAL_ALPHA,
showLegend = showLegend
)
}
in listOf("hist", "histogram") -> {
val bins = when {
bins2d == null -> null
side == 't' || side == 'b' -> bins2d.first
else -> bins2d.second
}
val binWidth = when {
binWidth2d == null -> null
side == 't' || side == 'b' -> binWidth2d.first
else -> binWidth2d.second
}
geomHistogram(
color = marginalColor,
fill = marginalColor,
alpha = MARGINAL_ALPHA,
bins = bins,
binWidth = binWidth,
showLegend = showLegend
)
}
in listOf("box", "boxplot") -> {
geomBoxplot(
color = marginalColor,
fill = marginalColor,
alpha = MARGINAL_ALPHA,
showLegend = showLegend
)
}
else -> {
throw IllegalArgumentException("Unknown geom: $geomKind")
}
}
return ggmarginal(side.toString(), size = size, layer = layer)
}