JetBrains / JetBrains/lets-plot-kotlin

asDiscrete: the levels parameter works inconsistently with values of int type

Open
#252 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
486
Forks
39
PR merge metrics
No merged PRs in 30d

Description

In the legend, I expect the order `3, 2, 1` (reversed, `order=-1`) for `levels=1, 2, 3`. The actual order is `2, 1, 3`, which looks like the reversed data order, i.e., the levels parameter is ignored:

```kotlin
%useLatestDescriptors
%use lets-plot

val d = mapOf(
"x" to listOf(0, 1, 2),
"v" to listOf(3, 1, 2),
)

ggplot(d) + geomPoint {
x = "x";
color = asDiscrete("v", levels=listOf(1, 2, 3), order=-1)
}
```

![image](https://github.com/user-attachments/assets/ad715d18-2d09-4a02-aec3-5bcfef09a144)

Without `order=-1`, the int levels are handled properly:
![image](https://github.com/user-attachments/assets/03d054f9-a134-4405-8eaa-b5c44965a99e)

With doubles, the `levels` parameters handled properly even with the `order` parameter:
![image](https://github.com/user-attachments/assets/0476cbea-2893-4620-9560-9b22e600e15a)

Version:
```
Lets-Plot Kotlin API v.4.7.3. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.3.3.
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.