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