Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

Matplotlib savefig() 함수에 대해 지원되는 파일 형식 목록을 검색하는 방법은 무엇입니까?

<시간/>

matplotlib savefig()에 대해 지원되는 파일 형식 목록을 검색하려면 함수에서 get_supported_filetypes()를 사용할 수 있습니다.

단계

  • 먼저 현재 수치를 가져옵니다.
  • 그림이 포함된 캔버스를 설정합니다.
  • get_supported_filetypes() 사용 방법.
  • 파일 유형 항목을 반복합니다.
  • 그림을 표시하려면 show()를 사용하세요. 방법.

예시

from matplotlib import pyplot as plt

fs = plt.gcf().canvas.get_supported_filetypes()

for key, val in fs.items():
print(key, ":", val)

출력

eps : Encapsulated Postscript
jpg : Joint Photographic Experts Group
jpeg : Joint Photographic Experts Group
pdf : Portable Document Format
pgf : PGF code for LaTeX
png : Portable Network Graphics
ps : Postscript
raw : Raw RGBA bitmap
rgba : Raw RGBA bitmap
svg : Scalable Vector Graphics
svgz : Scalable Vector Graphics
tif : Tagged Image File Format
tiff : Tagged Image File Format