Matplotlib是Python中廣泛使用的用於繪製各種圖形的庫,因為它提供了非常有效的方法,也為複雜圖提供了易於理解的方法。 pyplot是使matplotlib像MATLAB一樣工作的命令樣式函數的集合。
figimage()函數
matplotlib.pyplot.figimage()是一種用於向圖中添加未重采樣圖像的方法。通常,它會根據原點將圖像附加到左下角或左上角。
用法: matplotlib.pyplot.figimage(*args, **kwargs)
參數:
alpha是一個float值參數,用於給出圖像的混合值。它是一個可選參數。如果未指定,則默認值為“無”。
Xo,Yo是另一個重要參數,它說明圖像數據的形狀。通常可以是‘both’,‘x’或‘y’。它以像素為單位獲取x /y圖像偏移量。
** kwargs這是一個附加參數,通常稱為kwargs。它們是傳遞給FigureImage的Artist kwargs。
現在讓我們舉一個簡單的例子來說明matplotlib.pyplot.figimage()的工作。
範例1:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
fig = plt.figure()
Z = np.arange(10000).reshape((100, 100))
Z[:, 50:] = 1
im1 = fig.figimage(Z, xo = 50, yo = 0,
origin ='lower')
im2 = fig.figimage(Z, xo = 100, yo = 100,
alpha =.8, origin ='lower')
plt.show()
輸出:
範例2:
import numpy as np
import matplotlib.pyplot as plt
im = np.zeros((40, 40, 3), dtype = np.float)
fig, ax = plt.subplots()
im = fig.figimage(im, 100, 60)
ax.scatter([0, 1, 2, 3, 4], [0, 1, 2, 3, 4])
ax.set_zorder(1)
im.set_zorder(0)
ax.patch.set_visible(False)
plt.show()
輸出:
相關用法
- Python Wand function()用法及代碼示例
- Python cmp()用法及代碼示例
- Python sum()用法及代碼示例
- Python int()用法及代碼示例
- Python hex()用法及代碼示例
- Python tell()用法及代碼示例
- Python now()用法及代碼示例
- Python ord()用法及代碼示例
- Python oct()用法及代碼示例
- Python id()用法及代碼示例
- Python map()用法及代碼示例
- Python dir()用法及代碼示例
- Python str()用法及代碼示例
- Python fmod()用法及代碼示例
- Python randint()用法及代碼示例
注:本文由純淨天空篩選整理自rutujakawade24大神的英文原創作品 Matplotlib.pyplot.figimage() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。