One of the visualizations I find myself doing most often is the following: I have x,y Data, labeled in categories. I need to plot this in a scatterplot, automatically coloring the dots according to the label, and generating a legend. The visualization should then be interactive (zoomable, hovering over points shows Metadata, etc...)
This is the perfect example of what I am looking for - something that was existent in the now-deprecated bokeh.charts library:
I know I can do this non-interactively with seaborn:
fig = sns.lmplot(x="Length", y="Boot", hue="class", fit_reg=False, data=df)
I can plot interactively with bokeh, but only on a low level, without colors or legend:
p = Scatter(df, x="Length", y="Boot", plot_width=800, plot_height=600,
tooltips=TOOLTIPS, title="Cars")
I also know there exist various workarounds, manually defining color palettes, for example this one. However, this is ridiciously convoluted for something that used to be a simple oneliner (and still is, in R). The replacement, Holoview, does not seem to support coloring in scatterplots: Source
So, any recommendations for a Python package that supports this out-of-the-box in a oneliner, instead of manually writing this code on a low-level basis?
This is pretty trivial to achieve in modern versions of Bokeh:
from bokeh.plotting import figure, show
from bokeh.sampledata.iris import flowers as df
from bokeh.transform import factor_cmap
SPECIES = ['setosa', 'versicolor', 'virginica']
p = figure(tooltips="species: @species")
p.scatter("petal_length", "sepal_width", source=df, legend="species", alpha=0.5,
size=12, color=factor_cmap('species', 'Category10_3', SPECIES))
show(p)