I want to color my dots in a scatterplot with some rgb values.
Using the original api, this is easy:
import seaborn as sns
x = [0, 1, 2]
y = [0, 0, 0]
colors = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
sns.scatterplot(x=x, y=y, c=colors)
I get a red, a green and a blue dot.
But how do you do this with the objects api?
import seaborn.objects as so
so.Plot(x=x, y=y).add(so.Dot()).scale(color=colors)
This doesnt work. Depending where you put the color
argument you get different error messages.
Edit: The end result looks something like this. Some 3d coordinates represented as rgb values.
The solution with the hex colors works fine
hex_colors = [mpl.colors.rgb2hex(c) for c in colors]
so.Plot(x=x, y=y, color=hex_colors).add(so.Dot()).scale(color=None)
Only that Vscode tells me the types are incompatible:
Argument of type "list[str]" cannot be assigned to parameter "color" of type "VariableSpec" in function "__init__"
Argument of type "None" cannot be assigned to parameter "color" of type "Scale" in function "scale"