Revisit discussion around precomputed errorbars #3347
-
I have had a thorough look at the documentation and past issues on here, but feel sufficiently strongly about this feature that I thought I would present an argument for it again, though with a few additional points as well. I want to start out with a bit of praise: I am really enjoying Firstly, on a philosophical level I find it a bit too magical to have them computed for me, though this functionality can occasionally be nice and I am sure some people are really keen to do errorbars this way. Coming from physics, I often have dataframes with these precomputed using other techniques or need to do large bootstrappings which may be accelerated using custom code. The previous argument against adding the option to specify precomputed errorbars has been that these can easily be implemented using Given there is already the code in place to render errorbars, would it not be fairly easy to implement An example use-case: df = pd.DataFrame({
"x": [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
"y": [1, 2, 3, 4 ,5, 2, 4, 6, 8 ,10],
"yerr": [0.5, 0.25, 0.5, 0.75, 0.5, 0.25, 0.5, 0.75, 0.5, 0.25],
"cat": ["A"] * 5 + ["B"] * 5,
})
sns.lineplot(data=df, x="x", y="y", hue="cat")
# sns.lineplot(data=df, x="x", y="y", yerr="yerr", hue="cat") Ideally I would want to be able to use the bottom line. Considerations:
Apologies for reraising this issue, I understand completely if this is not something that seaborn wants to implement, but to me it seems like a really neat feature that might be fairly easy to implement. I think it is a feature that quite a few people want, judging from: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
For reference, my current workaround is: ax = sns.lineplot(data=a, x="temp", y="abs_mag_dens_mean", hue="size", palette="tab10")
for i, (name, group) in enumerate(a.groupby("size")):
x = group["temp"]
y = group["abs_mag_dens_mean"]
err = group["abs_mag_dens_sem"]
color = ax.get_lines()[i].get_c()
lower = y - err
upper = y + err
plt.fill_between(x, lower, upper, alpha=0.2, color=color) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I just found this and I'm a bit surpised of how things worked out, I used seaborn 0.12.2 for while to generate barplots, and I would just pass a list of custom error values to
|
Beta Was this translation helpful? Give feedback.
I guess you want one of these ?
Code is
(replace
Range
byBand
to get the other one)