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