Python으로 데이터 시각화 개선하기
Nick Strayer
Instructor

sns.palplot(sns.color_palette('Set2', 11))

# 원하는 조합으로 새 열 할당
pollution['interesting cities'] = [x if x in ['Long Beach', 'Cincinnati']
else 'other' for x in pollution['city'] ]
sns.scatterplot(x="NO2", y="SO2", hue = 'interesting cities', palette='Set2',
data=pollution.query('year == 2014 & month == 12'))

colorbrewer_palettes = ['Set1', 'Set2', 'Set3', 'Accent',
'Paired', 'Pastel1', 'Pastel2', 'Dark2']
for pal in colorbrewer_palettes:
sns.palplot(pal=sns.color_palette(pal))
plt.title(pal, loc = 'left')

범주 간에 순서가 있음
고정된 개수의 구분되는 범주

범주 간에 순서가 있음
고정된 개수의 구분되는 범주

범주 간에 순서가 있음
고정된 개수의 구분되는 범주

colorbrewer_palettes = ['Reds', 'Blues', 'YlOrBr', 'PuBuGn', 'GnBu', 'Greys']
for i, pal in enumerate(colorbrewer_palettes):
sns.palplot(pal=sns.color_palette(pal, n_colors=i+4))

# qcut()으로 삼등분(tertile) 컬럼 생성
pollution['NO2 Tertial'] = pd.qcut(pollution['NO2'], 3, labels = False)
# 계산된 삼등분으로 색상 인코딩하여 그리기
sns.scatterplot(x="CO", y="SO2", hue='NO2 Tertial', palette="OrRd",
data=pollution.query("city == 'Long Beach' & year == 2014"))

Python으로 데이터 시각화 개선하기