【发布时间】:2016-10-15 01:11:03
【问题描述】:
import numpy as np
import sys
import matplotlib as mpl
import matplotlib.pyplot as plt
我使用以下代码保存图像
fig, ax = plt.subplots(frameon=False)
ax.axis ('off')
ax.imshow (array[:,:,0,0,0])
fig.savefig ("file.png", bbox_inches='tight')
但是,我得到的是 这显然仍然有一个白色的边框。 我该如何摆脱它?
array.shape 为:(256, 256, 1, 1, 3)
【问题讨论】:
-
你可以尝试使用
savefig("file.png", bbox_inches = 'tight', pad_inches = 0)吗? -
已经试过了,也不管用...(实际上并没有改变任何东西)
-
没有完整的代码很难帮助你,因为问题来自图像的纵横比和 dpi。
-
添加了更多内容。我要绘制的数组被读入并具有给定的形状。实际上我的代码中没有更多内容
-
数组的形状是什么?
标签: python matplotlib figure imshow