Python 多图片背景matplotlib

Python 多图片背景matplotlib,python,image,matplotlib,background,Python,Image,Matplotlib,Background,我需要一些python绘图方面的帮助 我从文档中提取了一个示例,以便绘制如下内容: 但我现在的问题是,是否有可能用这种样式(正方形)绘制一个图,但在每个正方形上显示不同的图像 我想显示的图像将从计算机加载 因此,为了尽可能清楚:我想在正方形0,0上显示一个图像,在正方形0,1上显示一个不同的图像…等等。一种方法是将图像数组打包成一个大数组,然后在大数组上调用imshow: import numpy as np import matplotlib.pyplot as plt import mat

我需要一些python绘图方面的帮助

我从文档中提取了一个示例,以便绘制如下内容:

但我现在的问题是,是否有可能用这种样式(正方形)绘制一个图,但在每个正方形上显示不同的图像

我想显示的图像将从计算机加载


因此,为了尽可能清楚:我想在正方形0,0上显示一个图像,在正方形0,1上显示一个不同的图像…等等。

一种方法是将图像数组打包成一个大数组,然后在大数组上调用
imshow

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
import matplotlib.image as mimage
import scipy.misc as misc
import itertools as IT

height, width = 400, 400
nrows, ncols = 2, 4

# load some arrays into arrs
filenames = ['grace_hopper.png', 'ada.png', 'logo2.png']
arrs = list()
for filename in filenames:
    datafile = cbook.get_sample_data(filename, asfileobj=False)
    arr = misc.imresize(mimage.imread(datafile), (height, width))[..., :3]
    arrs.append(arr)
arrs = IT.islice(IT.cycle(arrs), nrows*ncols)

# make a big array
result = np.empty((nrows*height, ncols*width, 3), dtype='uint8')
for (i, j), arr in IT.izip(IT.product(range(nrows), range(ncols)), arrs):
    result[i*height:(i+1)*height, j*width:(j+1)*width] = arr

fig, ax = plt.subplots()
ax.imshow(result)
plt.show()