散点图中用形状和颜色区分不同类别数据
修改形状
import seaborn as sns
from matplotlib import pyplot as plt
tips = sns.load_dataset('tips')
sns.set_style('darkgrid')
ax = sns.scatterplot(x='total_bill', y='tip', hue='smoker', style='smoker',data=tips)
ax.legend(shadow=False, fancybox=False, ncol=1, fontsize=10, loc='upper left')
plt.show()
![](https://i-blog.csdnimg.cn/blog_migrate/f499a259e06544630786577e4f86bfcc.png)
修改颜色
import seaborn as sns
from matplotlib import pyplot as plt
tips = sns.load_dataset('tips')
sns.set_style('darkgrid')
ax = sns.scatterplot(x='total_bill', y='tip', hue='smoker', style='smoker', palette="ch:r=-.5,l=.75", data=tips)
ax.legend(shadow=False, fancybox=False, ncol=1, fontsize=10, loc='upper left')
plt.show()
![](https://i-blog.csdnimg.cn/blog_migrate/45592e6bd5c72c9afc13dd2eb537d170.png)
修改大小
import seaborn as sns
from matplotlib import pyplot as plt
tips = sns.load_dataset('tips')
sns.set_style('darkgrid')
ax = sns.scatterplot(x='total_bill', y='tip', hue='smoker', style='smoker', palette="ch:r=-.5,l=.75", size='smoker', sizes=(80, 20), data=tips)
ax.legend(shadow=False, fancybox=False, ncol=1, fontsize=10, loc='upper left')
plt.show()
![](https://i-blog.csdnimg.cn/blog_migrate/a7986e2704b036e4e0e32c89f25f06a7.png)