[Python/파이썬] Pandas Matplotlib - 생산자물가지수 plot
1. 엑셀 파일 불러오기
# 패키지 선언
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
from matplotlib import font_manager, rc
# 추출 및 변환 코드
df01=pd.read_excel('C:/fintech6/_project1/_src/생산자물가지수.xlsx', index_col=0)
*생산자물가지수.xlsx
2. plot 생성
# plot 생성
product_plot=df01.plot(grid=True,style=['-o'],markersize=4,
color=['indianred','darkcyan','mediumslateblue','steelblue','slategrey','darkgoldenrod'])
# 스타일 지정
str_plt_style = 'seaborn-darkgrid'
plt.style.use([str_plt_style])
plt.rcParams["figure.figsize"] = (10,5)
plt.rcParams["font.size"]=11
# 맑은고딕체 출력
font_path = "C:/Windows/Fonts/MALGUNBD.TTF"
font = font_manager.FontProperties(fname=font_path).get_name()
rc('font', family=font)
# plot 외부에 범례 배치
x = np.linspace(0, 1, 10)
plt.ylim([90, 125])
plt.legend(bbox_to_anchor=(1.01, 1.0), loc='upper left')
plt.tight_layout()
# 저장
image_file='C:/fintech6/_project1/_img/생산자물가지수.png'
plt.savefig(image_file,dpi=400)
댓글
댓글 쓰기