-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
lmplot and regplot both allow setting transparency for either scatterplot points or fit lines, through scatter_kws
and line_kws
, respectively. However, if x_estimator
is set (for example to np.mean
), then the scatterplot is replaced by confidence bars and a point at the estimated value. There is currently no way to set the transparency of these confidence bars.
For example:
sns.lmplot(data=example, x="x", y="y", hue="source", x_estimator=np.mean, scatter_kws={'s':20,'alpha':0.3}, line_kws={'alpha':0.3})
Creates an image like:
Since the two distributions I'm plotting stomp all over one another, I'd really like to make those estimation bars semi-transparent.
I believe the problem comes from the following lines:
Lines 398 to 407 in 0f538fb
# TODO abstraction | |
ci_kws = {"color": kws["color"]} | |
ci_kws["linewidth"] = mpl.rcParams["lines.linewidth"] * 1.75 | |
kws.setdefault("s", 50) | |
xs, ys, cis = self.estimate_data | |
if [ci for ci in cis if ci is not None]: | |
for x, ci in zip(xs, cis): | |
ax.plot([x, x], ci, **ci_kws) | |
ax.scatter(xs, ys, **kws) |
If x_estimator
is set, then scatterplot creates a new set of keywords, c_kws
, which inherits the color from the user-specified kws
, but no other values like alpha.
It seems reasonable to me that the confidence bars and scatterplot should share an alpha value, but if there's a compelling reason to keep those values distinct then it would be great if there were another way to specify the alpha values of those bars.