seaborn
seaborn copied to clipboard
Match the marker style in legend and figure when using size and style
Hi,
I am trying to make a 2D scatter plot using the hue and marker style as 3 different ways to jointly denote a third dimension (as done in this example, which yields a pretty result), and marker size to denote a fourth dimension.
This works perfectly when not using the marker style (i.e. sticking to the default dots):
g=sns.relplot(data=ks_df.iloc[::2,:], kind='scatter', hue='Kilosort version', x='N good units', y='N spikes per good unit', size='N good spikes', linewidth=30, legend=True)
But when I decide to add a style parameter, the marker style of the small symbol denoting the size in the legend isn't updated, it remains a circle instead of becoming a cross:
g=sns.relplot(data=ks_df.iloc[::2,:], kind='scatter', hue='Kilosort version', style='Kilosort version', markers={v:'+' for v in ks_df['Kilosort version']}, x='N good units', y='N spikes per good unit', size='N good spikes', linewidth=30, legend=True)
It seems that the legend only considers the size argument, does not account for the plot styling. Is there any way to make this work?
Thanks a lot!
Unfortunately there's no way to get what you want through the seaborn API, but you can always create a custom legend of your own using matplotlib.