Skip to content

Commit

Permalink
Inherit errorbar alpha from scatter points in regplot (#2853)
Browse files Browse the repository at this point in the history
* x_estimator bars now inherit scatter_kws alpha

x_estimator error bars were previously always opaque, but now inherit alpha settings from scatterplot settings, since the error bars replace the scatterplot

* Inherit errorbar alpha from scatter points in regplot

Closes #2540 by adding a test.

Co-authored-by: Milo Trujillo <[email protected]>
  • Loading branch information
mwaskom and milo-trujillo authored Jun 12, 2022
1 parent a674a83 commit fe9fad8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/releases/v0.12.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Other updates

- |Enhancement| When using :func:`pairplot` with `corner=True` and `diag_kind=None`, the top left y axis label is no longer hidden (:pr:2850`).

- |Enhancement| Error bars in :func:`regplot` now inherit the alpha value of the points they correspond to (:pr:`2540`).

- |Fix| Fixed a regression in 0.11.2 that caused some functions to stall indefinitely or raise when the input data had a duplicate index (:pr:`2776`).

- |Fix| Fixed a bug in :func:`histplot` and :func:`kdeplot` where weights were not factored into the normalization (:pr:`2812`).
Expand Down
2 changes: 2 additions & 0 deletions seaborn/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ def scatterplot(self, ax, kws):
else:
# TODO abstraction
ci_kws = {"color": kws["color"]}
if "alpha" in kws:
ci_kws["alpha"] = kws["alpha"]
ci_kws["linewidth"] = mpl.rcParams["lines.linewidth"] * 1.75
kws.setdefault("s", 50)

Expand Down
8 changes: 8 additions & 0 deletions tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,14 @@ def test_regplot_scatter_kws_alpha(self):
scatter_kws={'color': color})
assert ax.collections[0]._alpha == 0.8

f, ax = plt.subplots()
alpha = .3
ax = lm.regplot(x="x", y="y", data=self.df,
x_bins=5, fit_reg=False,
scatter_kws={"alpha": alpha})
for line in ax.lines:
assert line.get_alpha() == alpha

def test_regplot_binned(self):

ax = lm.regplot(x="x", y="y", data=self.df, x_bins=5)
Expand Down

0 comments on commit fe9fad8

Please sign in to comment.