본문 바로가기
Python Library/HeartPy

[HeartPy] Colorblind mode (1)

by goatlab 2022. 8. 25.
728x90
반응형
SMALL

Colorblind mode

 

1.2.4 이후로 HeartPy는 colorbilnd 모드가 플롯 API에 구현되어 있다. 여러 가지 다른 스타일을 사용할 수 있으며, deuteranopia (제2 색맹), protanopia (제 1색맹), tritanopia (제 3색맹)에 대한 지원이 가능하다.

heartpy.config를 통해 쉽게 사용할 수 있다.

 

heartpy.config.colorblind_type

 

지원하려는 colorbilnd 유형으로 설정한다.

 

  • deuteranopia (default)
  • protanopia
  • tritanopia

 

heartpy.config.color_style

 

원하는 색깔을 지정한다.

 

  • default (default)
  • retro
  • elegant
  • corporate
  • zesty
# load example data
import heartpy as hp

data, timer = hp.load_exampledata(2)
sample_rate = hp.get_samplerate_datetime(timer, timeformat = '%Y-%m-%d %H:%M:%S.%f')

# Analyze
wd, m = hp.process(data, sample_rate, clean_rr = True, high_precision = True)

# Visualize poincaré plot
hp.plot_poincare(wd, m)

# Set colorblind mode and visualise again!
hp.config.colorblind = True

# Now just run the plotter again and colors will be friendly for your type!
# Default colorblind mode is for deuteranopia
hp.plot_poincare(wd, m)

# But what if you have a different type? No problem, just tell HeartPy.
hp.config.colorblind_type = 'protanopia'

# change palette
hp.config.color_style = 'zesty'

# and plot again
hp.plot_poincare(wd, m)

# Let's visualise the available palettes
palettes = ['default', 'retro', 'elegant', 'corporate', 'zesty']

# First let's show you non colorblind palettes
hp.config.colorblind = False

for palette in palettes:
    hp.config.color_style = palette
    hp.plot_poincare(wd, m, title='color palette: %s' %palette)

# Now let's do colorblind deuteranopia friendly palettes
hp.config.colorblind = True
hp.config.colorblind_type = 'deuteranopia'

for palette in palettes:
    hp.config.color_style = palette
    hp.plot_poincare(wd, m, title='color palette: %s' %palette)

# Now let's do colorblind protanopia friendly palettes
hp.config.colorblind = True
hp.config.colorblind_type = 'protanopia'

for palette in palettes:
    hp.config.color_style = palette
    hp.plot_poincare(wd, m, title='color palette: %s' %palette)

 

https://github.com/paulvangentcom/heartrate_analysis_python/blob/master/examples/6_colorblind_mode/Colorblind_mode.ipynb

 

GitHub - paulvangentcom/heartrate_analysis_python: Python Heart Rate Analysis Package, for both PPG and ECG signals

Python Heart Rate Analysis Package, for both PPG and ECG signals - GitHub - paulvangentcom/heartrate_analysis_python: Python Heart Rate Analysis Package, for both PPG and ECG signals

github.com

 

728x90
반응형
LIST