Python savefig 去掉白色的margin

import matplotlib.pyplot as plt
fig = plt.figure(frameon=False)
fig.set_size_inches(w,h)
ax = plt.Axes(fig, [0., 0., 1., 1.])
ax.set_axis_off()
fig.add_axes(ax)
ax.imshow(your_image, aspect='normal')
fig.savefig(fname, dpi)

参考文献:
https://stackoverflow.com/questions/8218608/scipy-savefig-without-frames-axes-only-content

猜你喜欢

转载自blog.csdn.net/xuluhui123/article/details/80337550