파이썬 seaborn 모듈의 color palette

mr.dude·2022년 8월 2일
1

파이썬의 seaborn 모듈에서 컬러 팔레트 별 색상표이다. 데이터 시각화 - 지도라든가 - 에 사용하면 좋을 듯.

jet의 경우 오류가 발생하는데, 원인은...알고 싶지 않다. jet_r은 제대로 동작한다.

ValueError                                Traceback (most recent call last)
/tmp/ipykernel_223/1356115089.py in <module>
     20 # 'vlag', 'vlag_r', 'winter', 'winter_r'
     21 
---> 22 palette = seaborn.color_palette('jet', 20)
     23 seaborn.palplot(palette)

/usr/lib/python3/dist-packages/seaborn/palettes.py in color_palette(palette, n_colors, desat, as_cmap)
    172         elif palette.lower() == "jet":
    173             # Paternalism
--> 174             raise ValueError("No.")
    175 
    176         elif palette.startswith("ch:"):

ValueError: No.

prism의 경우, 색 수에 따라서 색상표가 달라진다.

윈도11/WSL2/Ubuntu-22.04에서 테스트했고, 파이썬 버전은 3.10.4, seaborn 버전은 0.11.2이다. 색상표 추출에 사용한 코드는 다음과 같다.

import seaborn

palette = seaborn.color_palette('winter', 20)
seaborn.palplot(palette)

결과는 알파벳 순(으로 보임). 색상표를 뒤집으려면 팔레트 이름 뒤에 "_r"을 붙인다.

팔레트색상표 (20색)
Accent
Blues
BrBG
BuGn
BuPu
CMRmap
Dark2
GnBu
Greens
Greys
OrRd
Oranges
PRGn
Paired
Pastel1
Pastel2
PiYG
PuBu
PuBuGn
PuOr
PuRd
Purples
RdBu
RdGy
RdPu
RdYlBu
RdYlGn
Reds
Set1
Set2
Set3
Spectral
Wistia
YlGn
YlGnBu
YlOrBr
YlOrRd
afmhot
autumn
binary
bone
brg
bwr
cividis
cool
coolwarm
copper
crest
cubehelix
flag
flare
gist_earth
gist_gray
gist_heat
gist_ncar
gist_rainbow
gist_stern
gist_yarg
gnuplot
gnuplot2
gray
hot
hsv
icefire
inferno
jet_r
magma
mako
nipy_spectral
ocean
pink
plasma
prism
rainbow
rocket
seismic
spring
summer
tab10
tab20
tab20b
tab20c
terrain
turbo
twilight
twilight_shifted
viridis
vlag
winter
profile
나는 왜 너가 아니고 나인가

0개의 댓글