Search
📈

시각화

2. Matplotlib

matplotlib 한글 설정

# 한글 표시를 위해 설치 !pip install koreanize_matplotlib -q import koreanize_matplotlib
Python
복사

Warning 무시하기

import warnings warnings.filterwarnings(action='ignore')
Python
복사

matplotlib 그리드와 틱 설정하기

matplotlib.pyplot의 grid와 tick 스타일을 지정할 수 있다.
plt.grid(True, axis=’y’, alpha=0.5, linestyle=’- -’)
첫 인자를 True로 지정하면, 그리드를 표시한다.
axis=’y’로 표시하면 가로 방향의 그리드만 표시한다.
alpha는 투명도다.
linestyle은 그리드 선의 스타일을 지정해준다.
plt.tick_params(axis=’both’, direction=’in’, length=3, pad=6, labelsize=14)
axis=’both’ 로 설정하면 x,y 축의 틱이 모두 적용된다.
direction=’in’ 은 틱의 방향을 그래프의 안쪽으로 그려준다.
length는 틱의 길이다.
pad는 틱과 레이블의 거리다.
labelsize는 틱 레이블의 크기를 지정해준다.

css 색상

matplotlib style 지정하기

cmap 종류

0 ~ 1 사이에서의 강도를 보여줄 경우
한가지 컬러를 중심으로 이뤄지는 colormap을 쓰는 것이 좋음
-1 ~ 1사이에서의 양/음의 강도를 보여줄 경우
음과 양에 따라 다른 컬러를 보여주는 colormap을 쓰는 것이 좋음
""" ['Accent', 'Accent_r', 'Blues', 'Blues_r', 'BrBG', 'BrBG_r', 'BuGn', 'BuGn_r', 'BuPu', 'BuPu_r', 'CMRmap', 'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Greens', 'Greens_r', 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges', 'Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 'Pastel2', 'Pastel2_r', 'PiYG', 'PiYG_r', 'PuBu', 'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu', 'RdBu_r', 'RdGy', 'RdGy_r', 'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', 'Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3', 'Set3_r', 'Spectral', 'Spectral_r', 'Wistia', 'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd', 'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cividis', 'cividis_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'cubehelix', 'cubehelix_r', 'flag', 'flag_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_heat', 'gist_heat_r', 'gist_ncar', 'gist_ncar_r', 'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 'gnuplot', 'gnuplot2', 'gnuplot2_r', 'gnuplot_r', 'gray', 'gray_r', 'hot', 'hot_r', 'hsv', 'hsv_r', 'inferno', 'inferno_r', 'jet', 'jet_r', 'magma', 'magma_r', 'nipy_spectral', 'nipy_spectral_r', 'ocean', 'ocean_r', 'pink', 'pink_r', 'plasma', 'plasma_r', 'prism', 'prism_r', 'rainbow', 'rainbow_r', 'seismic', 'seismic_r', 'spring', 'spring_r', 'summer', 'summer_r', 'tab10', 'tab10_r', 'tab20', 'tab20_r', 'tab20b', 'tab20b_r', 'tab20c', 'tab20c_r', 'terrain', 'terrain_r', 'turbo', 'turbo_r', 'twilight', 'twilight_r', 'twilight_shifted', 'twilight_shifted_r', 'viridis', 'viridis_r', 'winter', 'winter_r']
Plain Text
복사
출처:
[Rudi:티스토리]