0

Here's the least-square quadratic fitting result of my data: y = 0.06(+/- 0.16)x**2-0.65(+/-0.04)x+1.2(+/-0.001). I wonder is there a direct way to plot the fit as well as the error band? I found a similar example which used plt.fill_between method. However, in that example the boundaries are known, while in my case I'm not quite sure about the exact parameters which correspond to the boundaries. I don't know if I could use plt.fill_between or a different approach. Thanks!

ZR-
  • 809
  • 1
  • 4
  • 12

1 Answers1

1

You can use seaborn.regplot to calculate the fit and plot it directly (order=2 is second order fit):

Here is a dummy example:

import seaborn as sns
import numpy as np

xs = np.linspace(0, 10, 50)
ys = xs**2+xs+1+np.random.normal(scale=20, size=50)

sns.regplot(x=xs, y=ys, order=2)

seaborn regplot

mozway
  • 194,879
  • 13
  • 39
  • 75
  • 2
    I think this [question and answer](https://stackoverflow.com/questions/22852244/how-to-get-the-numerical-fitting-results-when-plotting-a-regression-in-seaborn) are important acknowledge with this answer, just to help OP understand since OP already has the fit and error. – m13op22 Aug 13 '21 at 16:36