본문 바로가기
Informations/python

matplot colormap, cmap 사용자 정의 팔렛트 만들기

by 지구별 이용자 2023. 6. 23.
# 그림용 데이터 프레임 생성
tmp = pd.DataFrame({'팔렛트만들기':list(range(38))})
tmp = tmp.T

# 사용할 팔렛트 불러오기
cmap = matplotlib.colors.LinearSegmentedColormap.from_list("", ['#cc3300','#ff9966','#ffcc00','#99cc33','#339900'])

# 그림그리기
plt.figure(figsize=(15,1))
ax = sns.heatmap(tmp,  cmap=cmap, linewidths=1, linecolor='white')
colorbar = ax.collections[0].colorbar
ax.set_xticklabels([])
plt.show()