martmists
07/12/2024, 1:50 PMUnequal column sizes. Expected rows count: 35. Actual column sizes:
x: 35
y: 35
x*: 31
My code:
val clusters = clusterKMeans(3, vectors)
plot {
points {
for ((cluster, clusterColor) in clusters.zip(colors)) {
x(cluster.map { it[0] })
y(cluster.map { it[1] })
color = clusterColor
}
}
}.save("kmeans-3.png")
Andrei Kislitsyn
07/12/2024, 2:32 PMAndrei Kislitsyn
07/12/2024, 2:33 PMplot {
points {
x(clusters.flatMap { cluster -> cluster.map { it[0] } })
y(clusters.flatMap { cluster -> cluster.map { it[1] } })
color(clusters.flatMapIndexed { index, cluster -> List(cluster.size) { index } }) {
scale = categorical(colors, colors.indices.toList())
}
}
}
martmists
07/12/2024, 3:55 PM"color" to colors.keys.map {
val r = (it[0] * 255).roundToInt()
val g = (it[1] * 255).roundToInt()
val b = (it[2] * 255).roundToInt()
Color.rgb(r, g, b)
}
and then specifying fillColor("color")
but that didn't seem to work, instead putting the colors as strings in a legend.Andrei Kislitsyn
07/12/2024, 4:03 PMidentity
color scale, so you should provide list of cluster labels into color
Andrei Kislitsyn
07/12/2024, 4:09 PMcolor
.
Example:
"color" to listOf("a", "b", "c", "a", etc)
fillColor("color") {
scale = categorical("a" to Color.RED, "b" to Color.BLUE, "c" to... )
scale = categorical("a" to Color.RED, "b" to Color.BLUE, "c" to... )
}Andrei Kislitsyn
07/12/2024, 4:16 PM