Я взял Ответ Дизиета и расширил его.Он создал необходимый синтаксис, который мне был нужен, но, как он указал, не нашел способа подсчитать, сколько строк легенды требуется для разделения легенды.Я добавил это и написал полный сценарий:
# Modules #
import seaborn
from matplotlib import pyplot
# Plot #
tips = seaborn.load_dataset("tips")
axes = seaborn.scatterplot(x="day", y="tip", size="sex", hue="time", data=tips)
# Legend split and place outside #
num_of_colors = len(tips['time'].unique()) + 1
handles, labels = axes.get_legend_handles_labels()
color_hl = handles[:num_of_colors], labels[:num_of_colors]
sizes_hl = handles[num_of_colors:], labels[num_of_colors:]
# Call legend twice #
color_leg = axes.legend(*color_hl,
bbox_to_anchor = (1.05, 1),
loc = 'upper left',
borderaxespad = 0.)
sizes_leg = axes.legend(*sizes_hl,
bbox_to_anchor = (1.05, 0),
loc = 'lower left',
borderaxespad = 0.)
# We need this because the 2nd call to legend() erases the first #
axes.add_artist(color_leg)
# Adjust #
pyplot.subplots_adjust(right=0.75)
# Display #
pyplot.ion()
pyplot.show()