-
When using the newish If this is the best way, what's the easiest way to assign a label to each line here so that there's a legend that distinguishes each line? import numpy as np
import seaborn.objects as so
_, ax = plt.subplots(figsize=(20, 10))
rng = np.random.default_rng()
data1 = rng.weibull(1, size=5_000)
data2 = rng.weibull(1.3, size=5_000)
(
so.Plot(data1)
.add(so.Line(color="C0",), so.KDE(bw_adjust=2))
.on(ax)
.plot()
)
(
so.Plot(data2)
.add(so.Line(color="C1"), so.KDE(bw_adjust=2))
.on(ax)
.plot()
) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Quick aside: I really like altair's API on combining plots, where if you have |
Beta Was this translation helpful? Give feedback.
-
Is what you're looking for here a layered plot? (
so.Plot()
.add(so.Line(color="C0"), so.KDE(bw_adjust=2), x=data1)
.add(so.Line(color="C1"), so.KDE(bw_adjust=2), x=data2)
) |
Beta Was this translation helpful? Give feedback.
-
Please add a comment about this use case to the Plot documentation. And perhaps to the tutorial as well. I had an issue with overplotting a line on a histogram. With only the x source specified in the constructor, it was not possible to then set x and y in the add. |
Beta Was this translation helpful? Give feedback.
Is what you're looking for here a layered plot?