lets-plot-kotlin icon indicating copy to clipboard operation
lets-plot-kotlin copied to clipboard

`scaleFillManual` doesn't work correctly with numbers

Open AndreiKingsley opened this issue 1 year ago • 2 comments

If domain of scale is numerical, scaleFillManual works like a continuous scale, even though it should work as discrete:

val yy = listOf(1, 2, 1, 2)
val cc = listOf(1, 2, 3, 4)

letsPlot() + geomTile() {
    x = xx
    y = yy
    fill = cc
} + scaleFillManual(values = listOf("red", "green", "blue", "yellow"), limits = listOf(1, 2, 3, 4))
image

AndreiKingsley avatar Dec 16 '24 11:12 AndreiKingsley

If limits are not specified, it works correctly: image

AndreiKingsley avatar Dec 16 '24 11:12 AndreiKingsley

This is expected behavior: scales created for a continuous (numeric) domain are continuous. Try asDiscrete() to annotate the domain as discrete.

alshan avatar Dec 16 '24 17:12 alshan