I am trying to plot multiple groups using scatter, when the groups are defined in a separate list. Like this:
from bokeh.plotting import figure, show
from bokeh.embed import components
from bokeh.palettes import viridis
import pandas as pd
data = pd.DataFrame({‘x’:[1,2,3,4,3], ‘y’:[1,2,4,4,1]})
groups = [‘a’,‘a’,‘b’,‘a’,‘b’]
colors = [‘red’,‘red’,‘black’,‘red’,‘black’]
p = figure()
p.scatter(data.x, data.y, color=colors) #this works
show(p)
p2 = figure()
p2.scatter(data.x, data.y, color=colors, legend=groups) #this does not
Suggestions? I noticed that I could use circle instead of scatter and go through all groups separately, but that quite inefficient and ugly solution (in practice I have arbitrary number of groups and thousands of points). Also, I would like to use same approach when I have projection from say scikit, so instead of passing data.x and data.y I would have something like *data.T.

