Python/맷플롯립

꺽은 선 그래프 예제

usop 2023. 1. 31. 16:53

         

문제)    mylist = [30,20,40,60,50] 을 이용하여 완성된 그래프를 보고 작성해보시오.

 

 

 

코드)

from pandas import Series
import matplotlib.pyplot as plt

plt.rcParams['font.family'] = 'Malgun Gothic'

mylist = [30, 20, 40, 60, 50]
myindex = ['이상화',  '한용운', '노천명', '윤동주', '이육사']

mys = Series(data=mylist, index=myindex)
myylim = [0, mys.max() + 10]
mys.plot(title='금월 실적', kind='line', ylim=myylim, grid=False, rot=10, use_index=True)

filename = 'Exam01_01.png'
plt.savefig(filename, dpi=400, bbox_inches='tight')
print(filename + '파일이 저장되었습니다.')

plt.show()

 

 

jupyter 코드)