3강 : 차트의 요소
3-1. Text 사용하기
fig.subtitle()
로 figuer의 제목을 설정할 수 있다.
ax.set_title(), ax.set_xlabel(), ax.set_ylabel()
로 subplot의 제목, x축, y축 label을 설정할 수 있다.
ax.text()
로 subplot에 text를 삽입할 수 있다.
- 기본적인 인자로 x, y, s를 받는다.
- Font Components로는 fontsize, fontweight, fontfamily 가 있다.
- Details로 color, linespacing, backgroundcolor, alpha, zoder, visible 등이 존재한다.
- Alignment와 관련된 요소로 ha, va, rotation, multialigment 등이 존재한다.
- bbox인자를 이용해 text의 테두리를 설정할 수 있다.
ax.text(x=0.5, y=0.5, s='Text\nis Important',
fontsize=20,
fontweight='bold',
fontfamily='serif',
color='royalblue',
linespacing=2,
va='center', # top, bottom, center
ha='center', # left, right, center
rotation='horizontal', # vertical?
bbox=dict(boxstyle='round', facecolor='wheat', alpha=0.4)
)
ax.legend()
에서 shadow=True
인자를 통해 그림자를 만들 수 있다. 또한 labelspacing, loc, bbox_to_anchor 인자도 존재한다.