patrickdelconte
02/14/2025, 7:05 PMscale
and axis
inside y()
without any luck, none of it worked. It seems like only the last usage of scale
makes it into the plot.
val wounds = listOf(4520, 3242, 3128, 3156, 4115, 5082, 5918, 3811, 5013, 6426, 5952, 5761, 5685, 5316, 4726, 4127, 4121, 3837, 3232, 2684, 2151, 1904, 1528, 1182, 971, 679, 564, 367, 276, 194, 111, 87, 59, 42, 19, 11, 1, 2)
val betterPercent = wounds.indices.map { x -> (wounds.filterIndexed { index, _ -> index > x }.sumOf { it } / wounds.sum().toDouble() * 100.0).roundToInt() }
plot() {
x(wounds.indices)
bars() {
y(wounds)
}
line {
y(betterPercent){
scale = continuous(0..100)
}
}
}
Andrei Kislitsyn
02/14/2025, 8:52 PMpatrickdelconte
02/16/2025, 11:33 AMAndrei Kislitsyn
02/16/2025, 2:18 PMval wounds = listOf(4520, 3242, 3128, 3156, 4115, 5082, 5918, 3811, 5013, 6426, 5952, 5761, 5685, 5316, 4726, 4127, 4121, 3837, 3232, 2684, 2151, 1904, 1528, 1182, 971, 679, 564, 367, 276, 194, 111, 87, 59, 42, 19, 11, 1, 2)
val betterPercent = wounds.indices.map { x -> (wounds.filterIndexed { index, _ -> index > x }.sumOf { it } / wounds.sum().toDouble() * 100.0).roundToInt() }
val woundsMax = wounds.max()
val woundsScaled = wounds.map { it.toDouble() / woundsMax * 100.0 }
plot() {
x(wounds.indices)
bars() {
y(woundsScaled)
}
line {
y(betterPercent){
scale = continuous(0..100)
}
}
}