Read csv file and save images from the output
Are you looking to simply save the file produced by plt.imshow? If yes, then you should be able to use plt.savefig as follows:
plt.imshow(data[1], cmap=&quot;gray&quot;)
plt.title(&quot;label: {0:}&quot;.format(label[1]))
plt.savefig(&quot;output_image.png&quot;)
plt.show()

You can either remove or keep the plt.show() call depending on whether you want the image to still be shown or just save the image.
EDIT: If you want to do this for all rows you can just loop through the numpy array as follows:
for i in range(data.shape[0])):
    plt.imshow(data[i], cmap=&quot;gray&quot;)
    plt.title(&quot;label: {0:}&quot;.format(label[1]))
    plt.savefig(f&quot;output_image_{i}.png&quot;)
    plt.close()