i am trying to generate a pie chart with lets-plot with Kotlin and i am unable to manually set colors to the sections of the chart. I am using org.jetbrains.lets-plot:lets-plot-kotlin-jvm:4.4.1
and the image export and Kotlin api dependencies.
Here is a minimal example:
val data = mapOf("name" to listOf("a", "b", "c", "d", "b"), "value" to listOf(40, 90, 10, 50, 20))
val plot = letsPlot(data) + scaleFillManual(values = listOf("#999999", "#E69F00", "#56B4E9","#999999", "#E69F00", "#56B4E9")) +
geomPie(size = 20, stroke = 1.0, tooltips = tooltipsNone)
{ fill = "name"; weight = "value"; slice = "value"}
ggsave(plot, filename)
But whatever i do, i get an OutOfBoundsException when using the scaleFillManual()
function to set the colors of the sections of the pie chart manually..
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
at java.base/java.util.Objects.checkIndex(Objects.java:361)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at jetbrains.datalore.plot.builder.assemble.PositionalScalesUtil.finalizeDomains(PositionalScalesUtil.kt:96)
...
I also cannot find any documentation or example which is explaining this feature. I have seen python syntax for this, but there is simply the list in brackets as argument..