다. 출판용 그래픽 파일을 생성할 때 내가 자주 사용하는 몇 가지 중요한 옵션이 있는데 바로
dpi
와
bbox
_
inches
다.
dpi
는 인치당 도트 해상도를 조절하고
bbox
_
inches
는 실제
figure
둘
레의 공백을 잘라낸다. 그래프 간 최소 공백을 가지는
400DPI
짜리
PNG
파일을 만들려면 아
래와 같이 입력한다.
plt
.
savefig
('
figpath
.
png
',
dpi
=
400
,
bbox
_
inches
=
'
tight
')
savefig
메서드는 파일에 저장할 뿐만 아니라
BytesIO
처럼 파일과 유사한 객체에 저장하는
것도 가능하다.
fromioimport BytesIO
buffer
=
BytesIO
()
plt
.
savefig
(
buffer
)
plot
_
data
=
buffer
.
getvalue
()
[표
9
-
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.