Python/데이터 시각화
[Matplotlib] 그래프 스타일 지정 (그래프 디자인 변경)
all_sound
2022. 9. 30. 10:20
스타일 서식 지정
- 색, 폰트 등 디자인적 요소를 사전에 지정된 스타일로 빠르게 일관 변경하는 것을 말한다.
- 스타일 서식을 지정하는 것은 matplotlib 환경 설정을 변경하는 것이므로 다른 파일에도 계속 적용된다.
▶ 사용 가능한 스타일 확인
print(plt.style.available)
['Solarize_Light2', '_classic_test_patch', 'bmh', 'classic', 'dark_background', 'fast', 'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn', 'seaborn-bright', 'seaborn-colorblind', 'seaborn-dark', 'seaborn-dark-palette', 'seaborn-darkgrid', 'seaborn-deep', 'seaborn-muted', 'seaborn-notebook', 'seaborn-paper', 'seaborn-pastel', 'seaborn-poster', 'seaborn-talk', 'seaborn-ticks', 'seaborn-white', 'seaborn-whitegrid', 'tableau-colorblind10']
▶ 스타일 직접 출력해서 확인
for i in plt.style.available: #사용 가능한 모든 스타일 출력하기
print() #플롯 사이사이 공백 추가
print('style:',i)
plt.style.use(i)
plt.figure(figsize=(5,2)) #사이즈 지정
plt.plot(sr_one.index, sr_one.values) #플롯 만들기
plt.show()
▶ 스타일 지정
plt.plot(sr_one.index, sr_one.values)
plt.style.use('seaborn-colorblind') #스타일 서식 지정