per-group baseline
in so.Bar
#3117
-
I am learning how to use the new objects interface (kudos btw it looks amazing 🚀) and I'm trying to create a simple box plot for different groups. My problem is that I can't work out how to move the baseline of a bar up so that it begins at the bottom quartile. Here is how far I've gotten thus far: import seaborn.objects as so
import numpy as np
data = sns.load_dataset("iris")
(
so.Plot(data, x="species", y="sepal_length")
.add(so.Range(), so.Est(errorbar=("pi", 95)))
.add(so.Dash(), so.Agg("median"))
.add(so.Dash(width=0.1), so.Agg(lambda x: np.percentile(x, 2.5)))
.add(so.Dash(width=0.1), so.Agg(lambda x: np.percentile(x, 97.5)))
# NOTE: How can I "lift" the bar / set baseline for each box?
# .add(so.Bar(), so.Agg(lambda x: np.percentile(x, 75)))
# NOTE: How do I add _only_ outliers (outside some threshold)?
# .add(so.Dot(alpha=0.2, edgealpha=1))
) There is also a question on how to add the outlier marks that you would get with |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
I think the question here is mostly "will there be a boxplot mark", and the answer is yes. |
Beta Was this translation helpful? Give feedback.
-
BTW you could make this existing plot a bit simpler with the (
so.Plot(iris, x="species", y="sepal_length")
.add(so.Dash(), so.Agg("median"))
.add(so.Dash(width=0.1), so.Perc([2.5, 97.5]))
.add(so.Range(), so.Perc([2.75, 97.5]))
) |
Beta Was this translation helpful? Give feedback.
-
As to the more specific questions — I'm not sure about a per-group bar baseline because I have on the roadmap a
I'm not sure about an "identify outliers" stat but it could make sense. By the way, a standard boxplot uses a more complicated rule than what you're using here to draw the whiskers: they're usually not showing a 95%ile interval, but a rule of "draw up to |
Beta Was this translation helpful? Give feedback.
-
I only do estimation at my actual job :) but probably pretty soon.
Ah I was indicating the "depending variable" i.e. opposite the orient variable. I don't really have a good consistent terminology for this yet.
Yeah this would be the right mark to use there and then you'd just need a transform to set the min/max (and maybe color) values appropriately for each group.
Sure, something like this makes plenty of sense. |
Beta Was this translation helpful? Give feedback.
I think the question here is mostly "will there be a boxplot mark", and the answer is yes.