I'm walking through a course on Seaborn and I'm having trouble understanding how exactly the x_bins
parameter in Seaborn's seaborn.regplot()
function works.
The documentation has the below:
Bin the x variable into discrete bins and then estimate the central tendency and a confidence interval. This binning only influences how the scatterplot is drawn; the regression is still fit to the original data. This parameter is interpreted either as the number of evenly-sized (not necessary spaced) bins or the positions of the bin centers.
So I understand that when I mention, say, x_bins = 5
, seaborn will bin the X-axis such that there is an equal (as much as possible) number of observations in each bin. And if I mention something like sns.regplot(data=mpg, x="weight", y="mpg", x_bins=np.arange(2000, 5500, 250), order=2)
(as given in the docs), the numbers are taken to be the bin centres.
My question: what exactly are the bin edges then? For example:
- In this figure from the docs, what are the first and second bins? Is it 1500 to some number between 1500 to 2,250?
- In this figure (from a DataCamp course), produced through the code below (by specifying the number of bins), is the first bin 0.0 to ~0.25, and the second bin ~0.25 to somewhere under ~0.4?
I'm having trouble understanding the creation of bins and where exactly the point representing the mean is made.