'Adding name_col and name_alpha to swimplot”翻译为'为游泳图添加name_col和name_alpha”,可通过以下代码实现:
import seaborn as sns import matplotlib.pyplot as plt
df = sns.load_dataset('titanic')
sns.swarmplot(x="class", y="age", data=df, hue="survived", palette="Set2", size=7, edgecolor="black", linewidth=0.5)
plt.title('为游泳图添加name_col和name_alpha') plt.xlabel('船舱等级') plt.ylabel('年龄') plt.legend(title='是否生还', loc='upper right') plt.show()