파이썬 데이터 분석 _ 시각화 결과 파일로 저장하기 : .savefig()
2025. 3. 9. 23:01ㆍLG U+ why not SW 5/python
파이썬
1. 모듈 import 및 데이터 추출, 시각화
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = 'AppleGothic'
myframe = pd.read_csv('./data/allStoreModified.csv', index_col=0, encoding='utf-8')
print(myframe['brand'].unique())
#한글화
brand_dict = {'cheogajip':'처가집', 'goobne':'굽네',
'nene':'네네', 'pelicana':'페리카나'}
mygrouping = myframe.groupby(['brand'])['brand']
chartData = mygrouping.count()
newindex = [brand_dict[idx] for idx in chartData.index]
chartData.index = newindex
mycolor = ['r', 'g', 'b', 'm']
plt.figure()
chartData.plot(kind = 'pie',
legend = False,
autopct = '%1.2f%%',
colors = mycolor)
filename = 'myChickenGragh01.png'
plt.savefig(filename, dpi=400, bbox_inches='tight')
print(filename + '이(가) 저장되었습니다!')
plt.show()
'LG U+ why not SW 5 > python' 카테고리의 다른 글
파이썬 데이터 분석 _ 결측치 처리 및 boxplot으로 이상치 처리 (0) | 2025.03.04 |
---|---|
파이썬 데이터 분석 _ matplot 라이브러리의 plot함수 기본 정리 (0) | 2025.03.03 |
파이썬 데이터 분석 _ pandas 라이브러리 활용 3 : 각종 함수 (0) | 2025.03.03 |
파이썬 데이터 분석 _ pandas 라이브러리 활용 2 : numpy (0) | 2025.03.02 |
파이썬 데이터 분석 _ pandas 라이브러리 활용 1 : Series / DataFrame (0) | 2025.03.02 |