การดึงรายการ File Formats ที่รองรับ
ใช้ get_supported_filetypes() จาก canvas ของ figure ปัจจุบัน
ขั้นตอนหลัก
- ดึง figure ปัจจุบันด้วย plt.gcf()
- เข้าถึง canvas และเรียก get_supported_filetypes()
- วนลูปแสดง key (extension) และ value (คำอธิบาย)
ตัวอย่างโค้ด
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
คำอธิบาย
รูปแบบที่รองรับอาจแตกต่างกันไปตาม backend และการติดตั้ง