如何檢索 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
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP