본문 바로가기

Python

Matplotlib color 색상표 SCI 논문 그림

RGB 튜플을 제외한 모든 색은 plt.plot(x, y, color='gray') 이런식으로 string으로 지정해주면 된다.

 

1. Base color

 

 

 

2. Tableau palette

 

 

3. CSS color

 

 

4. Black and white

0부터 1사이의 소수를 string으로 지정.

'0' = black, '0.3' = 진한 회색, '0.6' = 옅은 회색, '1'=흰색

논문은 흑백에 marker를 다르게 그리면 깔끔해보이기 때문에 사실상 이것을 제일 많이 사용한다.

 

 

5. RGB 튜플

RGB(Red, Green, Blue), RGBA( Red, Green, Blue, Alpha) 는 0부터 1사이의 튜플로 지정한다.

Alpha는 투명도로 0=완전투명, 1=완전불투명.

color = (0.1, 0.2, 0.5)

color = (0.1, 0.2, 0.5, 0.3)

 

 

6. Hex color

어도비에서 자주 사용하는 hex color code도 입력이 가능하다.

color = '#fbb0a9'

다음 사이트를 참고하자.

https://www.color-hex.com/

 

Color Hex Color Codes

Color Hex Color Codes Color-hex gives information about colors including color models (RGB,HSL,HSV and CMYK), Triadic colors, monochromatic colors and analogous colors calculated in color page. Color-hex.com also generates a simple css code for the selecte

www.color-hex.com

 

 

6. XKCD color (1000개)

 

얼추 이정도면 웬만한 색은 다 사용가능하다고 본다.

다음은 color_list와 for 문으로 색을 바꿔보면서 그래프를 그려보는 예시이다.

import matplotlib.pyplot as plt
import numpy as np

color_list = ['r', 'tab:brown', 'royalblue', '0.3', (0.1, 0.2, 0.5), '#ffcba4', 'xkcd:dull red']

x = np.linspace(0, 4, 100)
y = (x-2)**2+1

fig, ax = plt.subplots(len(color_list), 1, figsize=(4, 3*len(color_list)))

for i in range(len(color_list)):
    ax[i].plot(x, y, color=color_list[i], label=f'Line {i+1}')
    ax[i].legend()
    ax[i].set_title(f'Quadratic Function {i+1}')
    ax[i].set_xlabel('x')
    ax[i].set_ylabel('y')
    ax[i].grid(True)

plt.tight_layout()
plt.show()