Carter
01/26/2022, 5:20 PMIgor Alshannikov
01/26/2022, 9:12 PMasDiscrete()
function (see Python equivalent as_discrete
: https://lets-plot.org/pages/api/lets_plot.mapping.as_discrete.html?highlight=order)
In the simplest case your labels will be ordered alphabetically.
You can also add some numeric variable to your dataframe and use it for ordering instead (see orderBy
parameter).Carter
01/26/2022, 9:13 PMCarter
01/27/2022, 2:25 PMgeomLine(showLegend = true) {
x = X
y = Y
group = GROUPS
color = asDiscrete(LABELS, order = 1)
}
For my sleep data, it does make the visualizations more stable if each graph has the same set of labels.
However, I have another situation where all the labels may not always occur in a given set of data. (E.g. imagine a night where the user never has a moment of awake during sleep)
As far as I can tell, there’s not a good way to make the automatic color selection deterministic when the set of labels change unless there’s an explicit mapping of label to a specific color.Igor Alshannikov
01/27/2022, 10:02 PMscaleColorManual
is the way to go then. Try to pass a list of all labels via the breaks
parameter and a list of matching colors via the values
parameter. You can specify colors by their names or hex codes (i.e. strings like "#FF0000" for "red") or RGB strings : "rgb(255, 0, 0)" or instances of java.awt.Color.Carter
01/28/2022, 3:39 PMIgor Alshannikov
01/30/2022, 2:30 AM