1
我有一個matplotlib的問題。 我需要準備一個由指定目錄中的列表組成的圖。下面的代碼生成該代碼,但它省略了第一個路徑... 例如,如果我需要準備包含14個子圖的圖像,則只會複製13個圖像,首先會被省略,而不是第一個,最後會有一個空圖位置。 我檢查過,該函數讀取所有路徑,包括第一個列表。 如果你能夠幫助並給我一個提示,我會做錯什麼,我將不勝感激。 最好的問候爲什麼列表中的第一個數字沒有繪製,但最後還是有一個空的陰謀?
def create_combo_plot(path_to_dir, list_of_png_abspath):
name = path_to_dir.replace('_out', '')
title = name
if name.find('/') != -1:
title = name.split('/')[-1]
list_of_png_abspath
how_many_figures = len(list_)
combo_figure = plt.figure(2, figsize=(100,100))
a = 4
b = int(floor(how_many_figures/4.1)) + 1
for i, l in enumerate(list_of_png_abspath):
print l #I`ve checked, path is reached
j = i + 1
img=mpimg.imread(l)
imgplot = plt.imshow(img, interpolation="nearest")
plot = plt.subplot(b, a, j)
combo_figure.suptitle(title, fontsize=100)
combo_figure.savefig(path_to_dir +'/' + title + '.jpeg')
plt.close(combo_figure)
非常感謝!有用 – fafnir1990