plt.imshow(datalistall[i])
plt.axis('off')
# plt.gca().xaxis.set_major_locator(plt.NullLocator())
# plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.margins(0, 0)
plt.savefig('自己改一下要保存的地址', bbox_inches='tight', dpi=300, pad_inches=0.0)
plt.show()
测试下来,如果仅仅bbox_inches=‘tight’,最后保存的图片仅仅把白边变窄了。还要加上pad_inches=0.0。
中间注释掉的两句没有什么影响。
plt.show()一定要写在plt.savefig后面,不然的话会保存成一片空白。