本文簡要介紹 python 語言中 matplotlib.figure.Figure.figimage
的用法。
-
向圖中添加未重新采樣的圖像。
根據
origin
將圖像附加到左下角或左上角。- 參數:
- X
-
圖像數據。這是以下形狀之一的數組:
-
(M,N):具有標量數據的圖像。 Color-mapping 由
cmap
、norm
、vmin
和vmax
控製。 -
(M, N, 3):具有 RGB 值(0-1 float 或 0-255 int)的圖像。
-
(M, N, 4):具有 RGBA 值(0-1 float 或 0-255 int)的圖像,即包括透明度。
-
- xo, yo int
-
x
/y
圖像偏移(以像素為單位)。 - alpha 無或浮點數
-
Alpha 混合值。
- cmap str 或
Colormap
,默認值:rcParams["image.cmap"]
(默認值:'viridis'
) -
用於將標量數據映射到顏色的顏色圖實例或注冊的顏色圖名稱。
如果
X
為 RGB(A),則忽略此參數。 - norm str 或
Normalize
,可選 -
在使用
cmap
映射到顏色之前,用於將標量數據縮放到 [0, 1] 範圍的歸一化方法。默認情況下,使用線性縮放,將最低值映射到 0,將最高值映射到 1。如果給出,這可以是以下之一:
-
Normalize
或其子類之一的實例(請參閱顏色圖歸一化)。 -
比例名稱,即 "linear"、"log"、"symlog"、"logit" 等之一。有關可用比例的列表,請調用
matplotlib.scale.get_scale_names()
。在這種情況下,會動態生成並實例化合適的Normalize
子類。
如果
X
為 RGB(A),則忽略此參數。 -
- vmin, vmax 浮點數,可選
-
當使用標量數據並且沒有顯式
norm
時,vmin
和vmax
定義顏色圖覆蓋的數據範圍。默認情況下,顏色圖覆蓋所提供數據的完整值範圍。當給出norm
實例時,使用vmin
/vmax
是錯誤的(但使用str
norm
名稱和vmin
/vmax
是可以接受的)。如果
X
為 RGB(A),則忽略此參數。 - origin {'upper', 'lower'},默認:
rcParams["image.origin"]
(默認:'upper'
) -
指示數組的 [0, 0] 索引在坐標區的左上角或左下角的位置。
- resize bool
-
如果
True
,調整圖形大小以匹配給定的圖像大小。
- 返回:
- 其他參數:
- **kwargs
-
其他 kwargs 是
Artist
kwargs 傳遞給FigureImage
。
注意
figimage 補充了軸圖像(
imshow
),它將被重新采樣以適應當前軸。如果要重新采樣的圖像填充整個圖形,可以定義範圍為 [0, 0, 1, 1] 的Axes
。例子
f = plt.figure() nx = int(f.get_figwidth() * f.dpi) ny = int(f.get_figheight() * f.dpi) data = np.random.random((ny, nx)) f.figimage(data) plt.show()
用法
figimage(X, xo=0, yo=0, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, origin=None, resize=False, **kwargs)
相關用法
- Python matplotlib Figure.set_size_inches用法及代碼示例
- Python matplotlib Figure.add_axes用法及代碼示例
- Python matplotlib Figure.add_subplot用法及代碼示例
- Python matplotlib Figure.legend用法及代碼示例
- Python matplotlib Figure.savefig用法及代碼示例
- Python matplotlib Figure.colorbar用法及代碼示例
- Python matplotlib Figure.add_gridspec用法及代碼示例
- Python matplotlib Figure.sticky_edges用法及代碼示例
- Python matplotlib Figure.subplots用法及代碼示例
- Python matplotlib Figure.align_ylabels用法及代碼示例
- Python matplotlib Figure.align_xlabels用法及代碼示例
- Python matplotlib FigureBase.subplots用法及代碼示例
- Python matplotlib FigureBase.align_ylabels用法及代碼示例
- Python matplotlib FigureBase.align_xlabels用法及代碼示例
- Python matplotlib FigureBase.add_axes用法及代碼示例
- Python matplotlib FigureMpl用法及代碼示例
- Python matplotlib FigureBase.legend用法及代碼示例
- Python matplotlib FigureCanvasBase.mpl_connect用法及代碼示例
- Python matplotlib FigureBase.sticky_edges用法及代碼示例
- Python matplotlib FigureCanvasBase.mpl_disconnect用法及代碼示例
- Python matplotlib FigureBase.add_subplot用法及代碼示例
- Python matplotlib FigureBase.colorbar用法及代碼示例
- Python matplotlib FigureCanvasBase.new_timer用法及代碼示例
- Python matplotlib FigureBase.add_gridspec用法及代碼示例
- Python matplotlib FontManager用法及代碼示例
注:本文由純淨天空篩選整理自skytowner.com大神的英文原創作品 matplotlib.figure.Figure.figimage。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。