One way is to plot them separately, though you'll get different hues if not specified. Here's an example from the built-in tips
dataset with different alpha
values for smokers and non-smokers:
import seaborn as sns
import numpy as np
tips = sns.load_dataset("tips")
tips["alpha"] = np.where(tips.smoker == "Yes", 1.0, 0.5)
ax = sns.scatterplot(x="total_bill", y="tip",
data=tips[tips.alpha == 0.5], alpha=0.5)
sns.scatterplot(x="total_bill", y="tip", data=tips[tips.alpha == 1.0],
alpha=1.0, ax=ax)
This also stacks the higher-alpha points atop the lower ones.
More generally for multiple alpha
categories:
alphas = tips.alpha.sort_values().unique()
ax = sns.scatterplot(x="total_bill", y="tip",
data=tips[tips.alpha == alphas[0]], alpha=alphas[0])
for alpha in alphas[1:]:
sns.scatterplot(x="total_bill", y="tip",
data=tips[tips.alpha == alpha], alpha=alpha, ax=ax)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…