I'm trying to create a figure with seaborn lmplot. I use hue
to color the different levels for one category. But I'd like to have the marker shape for each point correspond to a different category than hue
. However sns.lmplot will only accept markers for the levels of hue.
Is there a way maybe use scatter_kws
to pass labels to the points, then somehow access the points within the AxesSubplots class within the seaborn.axisgrid.FacetGrid?
Simple example:
import seaborn as sns
import pandas as pd
snsdf = pd.DataFrame({'x' : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
'y' : [9, 9, 8, 6, 6, 4, 4, 3, 1, 1],
'hue' : ['tree', 'animal', 'animal', 'tree', 'animal'] * 2,
'marker' : ['o', 'o', '<', '<', 'o', '<', '<', '<', 'o', 'o']
})
# plot it normally
g = sns.lmplot(data=snsdf,
x='x',
y='y',
hue='hue',
scatter_kws{'label' : snsdf.marker})
# iterate objects in `g` to find points and change marker
# (i'm not sure about this part, but maybe accessing the label can tell me which marker the point should be? but I'm not sure where the actual points are where I could access the label)
thanks!