I have 2 sets of boxplots, one set in blue color and another in red color. I want the legend to show the label for each set of boxplots, i.e.
Legend: -blue box- A, -red box- B
Added labels='A'
and labels='B'
within sns.boxplot()
, but didn't work with error message "No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument". How do I add the labels?
Alternative approaches could be:
pd.melt
the dataframe to long form, sohue
could be used; a problem here is that then the legend wouldn't take thealpha
from theboxprops
into account; also setting different fliers wouldn't be supported- create a legend from custom handles