Seaborn 学习笔记(1.1)

散点图中用形状和颜色区分不同类别数据

修改形状

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()

Seaborn 学习笔记(1.1)_第1张图片

修改颜色

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()

Seaborn 学习笔记(1.1)_第2张图片

修改大小

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()

Seaborn 学习笔记(1.1)_第3张图片

你可能感兴趣的:(python,seaborn)