AI데이터엔지니어 부트캠프 <핀테커스> 6주차 - (1) Data Visualization with matplotlib

Lidit·2023년 10월 4일

3주차에 공부했던 matplotlib의 사용법 대해 좀더 자세히 알아보자

matplotlib

matplotlib.pyplot.figure() 을 이용해 figure 생성

import matplotlib.pyplot as plt

fig = plt.figure()

plt.show()

figure 생성시 지정해 줄수있는 속성은 아래와 같다

  • num
  • figsize
  • facecolor
  • 추가내용은 matplotlib의 공식문서 참조

생성된 figure 오브젝트에 subplots 추가

import matplotlib.pyplot as plt

fig = plt.figure(figsize=(7,7), facecolor='linen')
ax = fig.add_subplot()

plt.show()

figure 타이틀 지정하기

  • .suptitle('지정할 타이틀 텍스트')
    • fontsize
    • fontfamily
import matplotlib.pyplot as plt

figsize = (7, 7)
fig, ax = plt.subplots(figsize=figsize)
fig.suptitle("Title of a Figure", fontsize=30, fontfamily='monospace')

plt.show()

Ax의 타이틀 지정하기

  • ax.set_title('지정할 타이틀 텍스트')
    • fontsize
    • fontfamily
import matplotlib.pyplot as plt

figsize = (7, 7)
fig, ax = plt.subplots(figsize=figsize)
ax.set_title("Title of a Ax", fontsize=30, fontfamily='monospace')

plt.show()

0개의 댓글