Matplotlib

RGB, HEX 기본 색상 코드표

wx.Factory 2023. 4. 8. 13:27
반응형

 

 

Matplotlib 기본 색상표 수정버전

 

Matplotlib 기본 네임드 색상표

    파이썬 차트 라이브러리인 Matplotlib(https://matplotlib.org/2.0.2/examples/color/named_colors.html)에서는 총 148가지 기본 네임드 색상표를 제공합니다. 이름으로 색상을 직접 불러올 수 있고, 원하는대로 RGB나 다른 값으로 출력도 할 수 있습니다. 

 

   각 색상에 대한 HEX 코드는 아래와 같이 matplotlib.colors 모듈에 저장되어 있습니다. Jupyter Notebook에서  두 줄 짜리 코드를 입력 후 Shift+Enter를 치면 

import matplotlib.colors
import numpy as np 

for key, hex_value in matplotlib.colors.CSS4_COLORS.items():
    print("%20s : #%6s" % (key, hex_value))

    아래와 같이 결과가 출력됩니다. 색상 이름(Key값)과 HEX코드(Value값)의 쌍으로 이루어진 딕셔너리 형태인 것을 알 수 있습니다. 혹시 이름만 출력하고 싶으면 print(matplotlib.colors.CSS4_COLORS.keys()) 로 출력하시면 됩니다. 

 

 

'색상이름 : 색상 + HEX + RGB' 출력값

    위의 코드를 약간 수정하면 영문이름, 한글이름, 색상, HEX, RGB, HSV 값에 대한 테이블을 아래와 같이 멋지게 뽑아낼 수 있습니다. 색상을 고를 때 유용하게 쓸 수 있을 것 같네요. 표가 깨지시는 분들은 꼭 PC 버전에서 접속하세요~! 

 

Copyright(c) 2023. Hexa-Coding. All Rights Reserved.

색상명(한글)

색상명(영문)

컬러바

HEX

RGB

HSV

black

블랙

███████

#000000

[0 , 0 , 0]

[0.000 , 0.000 , 0.000]

dimgray

딤그레이

███████

#696969

[105 , 105 , 105]

[0.000 , 0.000 , 0.412]

dimgrey

딤그레이

███████

#696969

[105 , 105 , 105]

[0.000 , 0.000 , 0.412]

gray

그레이

███████

#808080

[128 , 128 , 128]

[0.000 , 0.000 , 0.502]

grey

그레이

███████

#808080

[128 , 128 , 128]

[0.000 , 0.000 , 0.502]

darkgray

다크그레이

███████

#A9A9A9

[169 , 169 , 169]

[0.000 , 0.000 , 0.663]

darkgrey

다크그레이

███████

#A9A9A9

[169 , 169 , 169]

[0.000 , 0.000 , 0.663]

silver

실버

███████

#C0C0C0

[192 , 192 , 192]

[0.000 , 0.000 , 0.753]

lightgray

라이트그레이

███████

#D3D3D3

[211 , 211 , 211]

[0.000 , 0.000 , 0.827]

lightgrey

라이트그레이

███████

#D3D3D3

[211 , 211 , 211]

[0.000 , 0.000 , 0.827]

gainsboro

게인스보로

███████

#DCDCDC

[220 , 220 , 220]

[0.000 , 0.000 , 0.863]

whitesmoke

화이트스모크

███████

#F5F5F5

[245 , 245 , 245]

[0.000 , 0.000 , 0.961]

white

화이트

███████

#FFFFFF

[256 , 256 , 256]

[0.000 , 0.000 , 1.000]

snow

스노우

███████

#FFFAFA

[256 , 250 , 250]

[0.000 , 0.020 , 1.000]

rosybrown

로지브라운

███████

#BC8F8F

[188 , 143 , 143]

[0.000 , 0.239 , 0.737]

lightcoral

라이트코럴

███████

#F08080

[240 , 128 , 128]

[0.000 , 0.467 , 0.941]

indianred

인디안레드

███████

#CD5C5C

[205 , 92 , 92]

[0.000 , 0.551 , 0.804]

brown

브라운

███████

#A52A2A

[165 , 42 , 42]

[0.000 , 0.745 , 0.647]

firebrick

파이어브릭

███████

#B22222

[178 , 34 , 34]

[0.000 , 0.809 , 0.698]

maroon

마룬

███████

#800000

[128 , 0 , 0]

[0.000 , 1.000 , 0.502]

darkred

다크레드

███████

#8B0000

[139 , 0 , 0]

[0.000 , 1.000 , 0.545]

red

레드

███████

#FF0000

[256 , 0 , 0]

[0.000 , 1.000 , 1.000]

mistyrose

미스티로즈

███████

#FFE4E1

[256 , 228 , 225]

[0.017 , 0.118 , 1.000]

salmon

살몬

███████

#FA8072

[250 , 128 , 114]

[0.017 , 0.544 , 0.980]

tomato

토마토

███████

#FF6347

[256 , 99 , 71]

[0.025 , 0.722 , 1.000]

darksalmon

다크살몬

███████

#E9967A

[233 , 150 , 122]

[0.042 , 0.476 , 0.914]

coral

코럴

███████

#FF7F50

[256 , 127 , 80]

[0.045 , 0.686 , 1.000]

orangered

오렌지레드

███████

#FF4500

[256 , 69 , 0]

[0.045 , 1.000 , 1.000]

lightsalmon

라이트살몬

███████

#FFA07A

[256 , 160 , 122]

[0.048 , 0.522 , 1.000]

sienna

시에나

███████

#A0522D

[160 , 82 , 45]

[0.054 , 0.719 , 0.627]

seashell

시셸

███████

#FFF5EE

[256 , 245 , 238]

[0.069 , 0.067 , 1.000]

chocolate

초콜릿

███████

#D2691E

[210 , 105 , 30]

[0.069 , 0.857 , 0.824]

saddlebrown

새들브라운

███████

#8B4513

[139 , 69 , 19]

[0.069 , 0.863 , 0.545]

sandybrown

샌디브라운

███████

#F4A460

[244 , 164 , 96]

[0.077 , 0.607 , 0.957]

peachpuff

피치퍼프

███████

#FFDAB9

[256 , 218 , 185]

[0.079 , 0.275 , 1.000]

peru

페루

███████

#CD853F

[205 , 133 , 63]

[0.082 , 0.693 , 0.804]

linen

리넨

███████

#FAF0E6

[250 , 240 , 230]

[0.083 , 0.080 , 0.980]

bisque

비스크

███████

#FFE4C4

[256 , 228 , 196]

[0.090 , 0.231 , 1.000]

darkorange

다크오렌지

███████

#FF8C00

[256 , 140 , 0]

[0.092 , 1.000 , 1.000]

burlywood

벌리우드

███████

#DEB887

[222 , 184 , 135]

[0.094 , 0.392 , 0.871]

antiquewhite

앤틱화이트

███████

#FAEBD7

[250 , 235 , 215]

[0.095 , 0.140 , 0.980]

tan

███████

#D2B48C

[210 , 180 , 140]

[0.095 , 0.333 , 0.824]

navajowhite

나바호화이트

███████

#FFDEAD

[256 , 222 , 173]

[0.100 , 0.322 , 1.000]

blanchedalmond

블랜치드아몬드

███████

#FFEBCD

[256 , 235 , 205]

[0.100 , 0.196 , 1.000]

papayawhip

파파야휩

███████

#FFEFD5

[256 , 239 , 213]

[0.103 , 0.165 , 1.000]

moccasin

모카신

███████

#FFE4B5

[256 , 228 , 181]

[0.106 , 0.290 , 1.000]

orange

오렌지

███████

#FFA500

[256 , 165 , 0]

[0.108 , 1.000 , 1.000]

wheat

███████

#F5DEB3

[245 , 222 , 179]

[0.109 , 0.269 , 0.961]

oldlace

올드레이스

███████

#FDF5E6

[253 , 245 , 230]

[0.109 , 0.091 , 0.992]

floralwhite

플로럴화이트

███████

#FFFAF0

[256 , 250 , 240]

[0.111 , 0.059 , 1.000]

darkgoldenrod

다크골든로드

███████

#B8860B

[184 , 134 , 11]

[0.118 , 0.940 , 0.722]

goldenrod

골든로드

███████

#DAA520

[218 , 165 , 32]

[0.119 , 0.853 , 0.855]

cornsilk

콘실크

███████

#FFF8DC

[256 , 248 , 220]

[0.133 , 0.137 , 1.000]

gold

골드

███████

#FFD700

[256 , 215 , 0]

[0.141 , 1.000 , 1.000]

lemonchiffon

레몬치폰

███████

#FFFACD

[256 , 250 , 205]

[0.150 , 0.196 , 1.000]

khaki

카키

███████

#F0E68C

[240 , 230 , 140]

[0.150 , 0.417 , 0.941]

palegoldenrod

페일골든로드

███████

#EEE8AA

[238 , 232 , 170]

[0.152 , 0.286 , 0.933]

darkkhaki

다크카키

███████

#BDB76B

[189 , 183 , 107]

[0.154 , 0.434 , 0.741]

ivory

아이보리

███████

#FFFFF0

[256 , 256 , 240]

[0.167 , 0.059 , 1.000]

beige

베이지

███████

#F5F5DC

[245 , 245 , 220]

[0.167 , 0.102 , 0.961]

lightyellow

라이트옐로우

███████

#FFFFE0

[256 , 256 , 224]

[0.167 , 0.122 , 1.000]

lightgoldenrodyellow

라이트골든로드옐로우

███████

#FAFAD2

[250 , 250 , 210]

[0.167 , 0.160 , 0.980]

olive

올리브

███████

#808000

[128 , 128 , 0]

[0.167 , 1.000 , 0.502]

yellow

옐로우

███████

#FFFF00

[256 , 256 , 0]

[0.167 , 1.000 , 1.000]

olivedrab

올리브드랩

███████

#6B8E23

[107 , 142 , 35]

[0.221 , 0.754 , 0.557]

yellowgreen

옐로우그린

███████

#9ACD32

[154 , 205 , 50]

[0.222 , 0.756 , 0.804]

darkolivegreen

다크올리브그린

███████

#556B2F

[85 , 107 , 47]

[0.228 , 0.561 , 0.420]

greenyellow

그린옐로우

███████

#ADFF2F

[173 , 256 , 47]

[0.232 , 0.816 , 1.000]

chartreuse

차트리우즈

███████

#7FFF00

[127 , 256 , 0]

[0.250 , 1.000 , 1.000]

lawngreen

런그린

███████

#7CFC00

[124 , 252 , 0]

[0.251 , 1.000 , 0.988]

honeydew

허니듀

███████

#F0FFF0

[240 , 256 , 240]

[0.333 , 0.059 , 1.000]

darkseagreen

다크씨그린

███████

#8FBC8F

[143 , 188 , 143]

[0.333 , 0.239 , 0.737]

palegreen

페일그린

███████

#98FB98

[152 , 251 , 152]

[0.333 , 0.394 , 0.984]

lightgreen

라이트그린

███████

#90EE90

[144 , 238 , 144]

[0.333 , 0.395 , 0.933]

forestgreen

포레스트그린

███████

#228B22

[34 , 139 , 34]

[0.333 , 0.755 , 0.545]

limegreen

라임그린

███████

#32CD32

[50 , 205 , 50]

[0.333 , 0.756 , 0.804]

darkgreen

다크그린

███████

#006400

[0 , 100 , 0]

[0.333 , 1.000 , 0.392]

green

그린

███████

#008000

[0 , 128 , 0]

[0.333 , 1.000 , 0.502]

lime

라임

███████

#00FF00

[0 , 256 , 0]

[0.333 , 1.000 , 1.000]

seagreen

씨그린

███████

#2E8B57

[46 , 139 , 87]

[0.407 , 0.669 , 0.545]

mediumseagreen

미디움씨그린

███████

#3CB371

[60 , 179 , 113]

[0.408 , 0.665 , 0.702]

springgreen

스프링그린

███████

#00FF7F

[0 , 256 , 127]

[0.416 , 1.000 , 1.000]

mintcream

민트크림

███████

#F5FFFA

[245 , 256 , 250]

[0.417 , 0.039 , 1.000]

mediumspringgreen

미디엄스프링그린

███████

#00FA9A

[0 , 250 , 154]

[0.436 , 1.000 , 0.980]

mediumaquamarine

미디엄아쿠아마린

███████

#66CDAA

[102 , 205 , 170]

[0.443 , 0.502 , 0.804]

aquamarine

아쿠아마린

███████

#7FFFD4

[127 , 256 , 212]

[0.444 , 0.502 , 1.000]

turquoise

터쿼즈

███████

#40E0D0

[64 , 224 , 208]

[0.483 , 0.714 , 0.878]

lightseagreen

라이트씨그린

███████

#20B2AA

[32 , 178 , 170]

[0.491 , 0.820 , 0.698]

mediumturquoise

미디엄터쿼즈

███████

#48D1CC

[72 , 209 , 204]

[0.494 , 0.656 , 0.820]

azure

애저

███████

#F0FFFF

[240 , 256 , 256]

[0.500 , 0.059 , 1.000]

lightcyan

라이트사이언

███████

#E0FFFF

[224 , 256 , 256]

[0.500 , 0.122 , 1.000]

paleturquoise

페일터쿼즈

███████

#AFEEEE

[175 , 238 , 238]

[0.500 , 0.265 , 0.933]

darkslategray

다크슬레이트그레이

███████

#2F4F4F

[47 , 79 , 79]

[0.500 , 0.405 , 0.310]

darkslategrey

다크슬레이트그레이

███████

#2F4F4F

[47 , 79 , 79]

[0.500 , 0.405 , 0.310]

teal

███████

#008080

[0 , 128 , 128]

[0.500 , 1.000 , 0.502]

darkcyan

다크사이언

███████

#008B8B

[0 , 139 , 139]

[0.500 , 1.000 , 0.545]

aqua

아쿠아

███████

#00FFFF

[0 , 256 , 256]

[0.500 , 1.000 , 1.000]

cyan

사이언

███████

#00FFFF

[0 , 256 , 256]

[0.500 , 1.000 , 1.000]

darkturquoise

다크터쿼즈

███████

#00CED1

[0 , 206 , 209]

[0.502 , 1.000 , 0.820]

cadetblue

카디엣블루

███████

#5F9EA0

[95 , 158 , 160]

[0.505 , 0.406 , 0.627]

powderblue

파우더블루

███████

#B0E0E6

[176 , 224 , 230]

[0.519 , 0.235 , 0.902]

lightblue

라이트블루

███████

#ADD8E6

[173 , 216 , 230]

[0.541 , 0.248 , 0.902]

deepskyblue

딥스카이블루

███████

#00BFFF

[0 , 191 , 256]

[0.542 , 1.000 , 1.000]

skyblue

스카이블루

███████

#87CEEB

[135 , 206 , 235]

[0.548 , 0.426 , 0.922]

lightskyblue

라이트스카이블루

███████

#87CEFA

[135 , 206 , 250]

[0.564 , 0.460 , 0.980]

steelblue

스틸블루

███████

#4682B4

[70 , 130 , 180]

[0.576 , 0.611 , 0.706]

aliceblue

앨리스블루

███████

#F0F8FF

[240 , 248 , 256]

[0.578 , 0.059 , 1.000]

dodgerblue

도저블루

███████

#1E90FF

[30 , 144 , 256]

[0.582 , 0.882 , 1.000]

lightslategray

라이트슬레이트그레이

███████

#778899

[119 , 136 , 153]

[0.583 , 0.222 , 0.600]

lightslategrey

라이트슬레이트그레이

███████

#778899

[119 , 136 , 153]

[0.583 , 0.222 , 0.600]

slategray

슬레이트그레이

███████

#708090

[112 , 128 , 144]

[0.583 , 0.222 , 0.565]

slategrey

슬레이트그레이

███████

#708090

[112 , 128 , 144]

[0.583 , 0.222 , 0.565]

lightsteelblue

라이트스틸블루

███████

#B0C4DE

[176 , 196 , 222]

[0.594 , 0.207 , 0.871]

cornflowerblue

콘플라워블루

███████

#6495ED

[100 , 149 , 237]

[0.607 , 0.578 , 0.929]

royalblue

로얄블루

███████

#4169E1

[65 , 105 , 225]

[0.625 , 0.711 , 0.882]

ghostwhite

고스트화이트

███████

#F8F8FF

[248 , 248 , 256]

[0.667 , 0.027 , 1.000]

lavender

라벤더

███████

#E6E6FA

[230 , 230 , 250]

[0.667 , 0.080 , 0.980]

midnightblue

미드나잇블루

███████

#191970

[25 , 25 , 112]

[0.667 , 0.777 , 0.439]

navy

네이비

███████

#000080

[0 , 0 , 128]

[0.667 , 1.000 , 0.502]

darkblue

다크블루

███████

#00008B

[0 , 0 , 139]

[0.667 , 1.000 , 0.545]

mediumblue

미디엄블루

███████

#0000CD

[0 , 0 , 205]

[0.667 , 1.000 , 0.804]

blue

블루

███████

#0000FF

[0 , 0 , 256]

[0.667 , 1.000 , 1.000]

slateblue

슬레이트블루

███████

#6A5ACD

[106 , 90 , 205]

[0.690 , 0.561 , 0.804]

darkslateblue

다크슬레이트블루

███████

#483D8B

[72 , 61 , 139]

[0.690 , 0.561 , 0.545]

mediumslateblue

미디엄슬레이트블루

███████

#7B68EE

[123 , 104 , 238]

[0.690 , 0.563 , 0.933]

mediumpurple

미디엄퍼플

███████

#9370DB

[147 , 112 , 219]

[0.721 , 0.489 , 0.859]

rebeccapurple

레베카퍼플

███████

#663399

[102 , 51 , 153]

[0.750 , 0.667 , 0.600]

blueviolet

블루바이올렛

███████

#8A2BE2

[138 , 43 , 226]

[0.753 , 0.810 , 0.886]

indigo

인디고

███████

#4B0082

[75 , 0 , 130]

[0.763 , 1.000 , 0.510]

darkorchid

다크오키드

███████

#9932CC

[153 , 50 , 204]

[0.778 , 0.755 , 0.800]

darkviolet

다크바이올렛

███████

#9400D3

[148 , 0 , 211]

[0.784 , 1.000 , 0.827]

mediumorchid

미디엄오키드

███████

#BA55D3

[186 , 85 , 211]

[0.800 , 0.597 , 0.827]

thistle

시슬

███████

#D8BFD8

[216 , 191 , 216]

[0.833 , 0.116 , 0.847]

plum

플럼

███████

#DDA0DD

[221 , 160 , 221]

[0.833 , 0.276 , 0.867]

violet

바이올렛

███████

#EE82EE

[238 , 130 , 238]

[0.833 , 0.454 , 0.933]

purple

퍼플

███████

#800080

[128 , 0 , 128]

[0.833 , 1.000 , 0.502]

darkmagenta

다크마젠타

███████

#8B008B

[139 , 0 , 139]

[0.833 , 1.000 , 0.545]

fuchsia

퍼크샤

███████

#FF00FF

[256 , 0 , 256]

[0.833 , 1.000 , 1.000]

magenta

마젠타

███████

#FF00FF

[256 , 0 , 256]

[0.833 , 1.000 , 1.000]

orchid

오키드

███████

#DA70D6

[218 , 112 , 214]

[0.840 , 0.486 , 0.855]

mediumvioletred

미디엄바이올렛레드

███████

#C71585

[199 , 21 , 133]

[0.895 , 0.894 , 0.780]

deeppink

딥핑크

███████

#FF1493

[256 , 20 , 147]

[0.910 , 0.922 , 1.000]

hotpink

핫핑크

███████

#FF69B4

[256 , 105 , 180]

[0.917 , 0.588 , 1.000]

lavenderblush

라벤더블러쉬

███████

#FFF0F5

[256 , 240 , 245]

[0.944 , 0.059 , 1.000]

palevioletred

페일바이올렛레드

███████

#DB7093

[219 , 112 , 147]

[0.945 , 0.489 , 0.859]

crimson

크림슨

███████

#DC143C

[220 , 20 , 60]

[0.967 , 0.909 , 0.863]

pink

핑크

███████

#FFC0CB

[256 , 192 , 203]

[0.971 , 0.247 , 1.000]

lightpink

라이트핑크

███████

#FFB6C1

[256 , 182 , 193]

[0.975 , 0.286 , 1.000]

    

 

 

 

 

   출처 사이트를 방문하면 위 색상표 출력에 대한 코드도 게시되어 있으나, 아쉽게도 RGB나 HEX 코드는 공개되어 있지 않아 제가 공개된 코드를 약간 수정하여 RGB, HEX값도 같이 출력하도록 만들었습니다. 코드는 아래 예제를 통해 참조하시면 되고, 혹시나 퍼가실때에는 링크 남겨주세요. ^^ 

 

 

예제 

    아래 예제는 Matplotlib 공식사이트의 코드를 수정한 버전입니다. 본 글의 상단에 있는 메인 이미지를 만들기 위한 코드입니다. 

"""
========================
Visualizing named colors
========================

Simple plot example with the named colors and its visual representation.
"""
from __future__ import division

import matplotlib.pyplot as plt
import numpy as np 
from matplotlib import colors as mcolors



colors = dict(**mcolors.CSS4_COLORS)

# Sort colors by hue, saturation, value and name.
by_hsv = sorted((tuple(mcolors.rgb_to_hsv(mcolors.to_rgba(color)[:3])), name)
                for name, color in colors.items())

sorted_names = [name for hsv, name in by_hsv]

n = len(sorted_names)
ncols = 4
nrows = n // ncols + 1

fig, ax = plt.subplots(figsize=(12, 23), dpi=200)

# Get height and width
X, Y = fig.get_dpi() * fig.get_size_inches()
h = 40 #Y / (nrows + 1)
w = X / ncols

for i, name in enumerate(sorted_names):
    col = i % ncols
    row = i // ncols
    y = Y - 3*(row * h) - h*3

    xi_line = w * (col + 0.05)
    xf_line = w * (col + 0.25)
    xi_text = w * (col + 0.3)

    # [R,G,B] + color_name 
    rgb_value = [n*255 for n in mcolors.to_rgb(name)]
    hex_value = mcolors.to_hex(name)
    color_name = "RGB  : " + str(rgb_value) + "\nHEX  : " + str(hex_value) + "\nNAME: " + name 
    color_name = color_name.replace(".0","")
    ax.text(xi_text, y, color_name, fontsize=(10),
            horizontalalignment='left',
            verticalalignment='center')

    ax.hlines(y, xi_line, xf_line,
              color=colors[name], linewidth=(30))


ax.set_xlim(0, X)
ax.set_ylim(0, Y)
ax.set_axis_off()
ax.set_title("[Matplotlib Named Colors]", fontsize=25)
ax.text(x=X*0.96, y=Y*0.99, s="[HEXA-CODING] https://hexa-coding.tistory.com", ha='right', va='center', color='gray', fontsize=9)
fig.subplots_adjust(left=0, right=1,
                    top=1, bottom=0,
                    hspace=0, wspace=0)
plt.show()
fig.savefig("./named_colors_mpl.png", bbox_inches = 'tight')

 

 

 

   혹시 다른 색상표도 코딩으로 만들고 싶다면 댓글로 요청해주시면 검토해볼게요~! 

 

 

 

반응형