전체 그래프 세팅
plt.rc('font',family='Malgun Gothic', size = 20, weight = 'bold') #한글폰트 적용
plt.rc('figure',figsize = (10,7)) #크기설정
plt.rc('axes', grid = True) #격자 on,off
#plt.rc('lines', color = 'y', linewidth = 4,linestyle = '--') # 라인설정
#plt.rc('grid', color = 'k', linewidth = 1, linestyle = ':')# 그리드설정
#plt.rc('legend', loc = 'center left') #범레위치
plt.rc('savefig', transparent = True) #저장설정(transparent 배경 투명색)
plt.rcParams['axes.unicode_minus'] = False # 한글시 - 깨짐방지
개별 그래프 세팅
가로 막대그래프
plt.figure(figsize=(10,10))
ax = plt.barh(y,width .values,color = 'b',alpha= 0.3) #투명도 조절
plt.title('title')
for patch in ax.patches: #값 annotation
x, y, width, height = patch.get_bbox().bounds
plt.text(width*1.01, y+height/2, round(width,2), va='center')
plt.box() #그래프 박스제거 (보통은 없는게 더 깔끔)
plt.tightlayout() #파일 저장할때 깨지지 않게끔
plt.grid(axis= 'x', which = 'major') #y축 보조선만(가로막대그래프일때 유용)
plt.legend(loc = 'center left', bbox_to_anchor = (1,0.5)) #범례를 그래프 바깥에 그릴때
댓글