This is super clunky, probably because handling legends in the seaborn.objects interface is a work in progress but this seems to get close to what you want, I think?
In a first cell use an example from the posted solution there.
import seaborn as sns
import matplotlib.pyplot as plt
import seaborn.objects as so
tips = sns.load_dataset("tips")
f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)
(
so.Plot(tips, x='total_bill', y='tip', color='day')
.add(so.Dot(pointsize=2))
.add(so.Line(color='k'), so.PolyFit(order=1), color=None)
.on(ax1)
.plot()
)
legend = f.legends.pop(0)
ax1.legend(legend.legendHandles, [t.get_text() for t in legend.texts]);

(I know that code and plot above has nothing to do with what you want; however, it imports something or sets up something that I couldn't get the code I thought should be all you need (below) to do on it's own. Needing that unrelated code and plot is why I say it's super clunky. But I couldn't get it to work without it, and it worked fairly well when I had it there and so I'm sharing. Maybe it will factor into figuring out a cleaner solution.)
In the next cell, put this variation of your code:
import seaborn as sns
import seaborn.objects as so
import matplotlib as mpl
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
f = mpl.figure.Figure(figsize=(8, 2), dpi=100)
sf1, sf2 = f.subfigures(1, 2)
(
so.Plot(tips, "total_bill", "tip", color="day")
.facet(col="day")
.add(so.Dot(color="#aabc"), col=None, color=None)
.add(so.Dot())
.on(sf1)
.plot()
)
(
so.Plot(tips, "total_bill", "tip")
.add(so.Dot(color="#aabc"))
.add(so.Dot(), data=tips.query("size == 1"), color="time")
.on(sf2)
.plot()
)
legend = f.legends.pop(1)
f.legends.pop(0) # don't need the 'day' legend showing, so use this
sf2.legend(legend.legendHandles, [t.get_text() for t in legend.texts])
f.figure
Run that and it should look a little better without the two legends overlapping on the far right side.
I didn't see why you need the 'day' legend showing because that is clearly handled in the plots on the left panel , and so I used the pop
method to remove it.
