파이썬. 데이터분석/Matplotlib
지금까지 배운거 복습 : enumerate, grid, legend
한국수달보호협회장
2022. 7. 11. 22:53
df
바로 plt.plot으로 그려본다. 밋밋하다
배운거 한가지씩 해보려고하니까 복잡해졌다.
grid는 전역설정 방법이 plt.rcParams['axes.grid'] = True
십자무늬 grid가 생긴다. 나는 y축만하고싶어서 plt.grid(axis='y')로 했다
enumerate에 df['영어']같은 Series도 가능할까했는데 넣어보니까 됐다.
plt.plot(df['지원번호'], df['영어'], label='영어점수', color = 'blue')
plt.plot(df['지원번호'], df['수학'], label='수학점수', color = 'red')
for idx, txt in enumerate(df['영어']):
plt.text(df['지원번호'][idx], df['영어'][idx], txt, color='blue')
for idx, txt in enumerate(df['수학']):
plt.text(df['지원번호'][idx], df['수학'][idx], txt, color='red')
plt.grid(axis='y', color='purple', alpha=0.9, ls='--', linewidth = 1.5)
plt.legend()