7

I am using a seaborn scatterplot and just started using different point sizes.

sns.scatterplot(x='X [um]', y='Y [um]', hue='label', size='size', data=data)

All works perfectly but I'd like to remove the 'size' from the legend seen in picture: enter image description here

The upper part with CH1, etc. shall remain the same but I'd want the lower part where the sizes are listed to vanish.

Benjamin Jabl
  • 231
  • 2
  • 7
  • Does this answer your question? [Remove one out of two legends from Seaborn Scatterplot](https://stackoverflow.com/questions/62163460/remove-one-out-of-two-legends-from-seaborn-scatterplot) – Trenton McKinney May 02 '22 at 15:55

1 Answers1

6

I use the get_legend_handles_labels() functionality to index the labels. Using indexing, I ensure that the final printed image only contains the first 13 labels in your legend.

 g = sns.scatterplot(x='X [um]', y='Y [um]', hue='label', size='size', data=data)
    h,l = g.get_legend_handles_labels()
    plt.legend(h[0:13],l[0:13],bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
    plt.show(g)
JodeCharger100
  • 903
  • 1
  • 12
  • 25