以極高質量儲存 Python 中的影像
要以非常高的質量儲存 Python 中的影像,你需要按照以下步驟操作 -
使用子圖方法建立 fig 和 ax 變數,其中預設的 nrows 和 ncols 為 1。
使用 plot() 方法繪製線條。
我們可以使用 ylabel() 和 xlabel() 新增軸標籤。
要獲得高質量的影像,我們可以使用 .eps 影像格式。
你可以增加每英寸點數,即 dpi。
我們可以使用 savefig() 方法在本地儲存影像。
若要顯示圖片,請使用 plt.show()。
示例
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
plt.plot([0, 5], [0, 5])
plt.ylabel("Y-axis ")
plt.xlabel("X-axis ")
image_format = 'eps' # e.g .png, .svg, etc.
image_name = 'myimage.eps'
fig.savefig(image_name, format=image_format, dpi=1200)輸出

廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
安卓
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP