1.设置画图尺寸
plt.figure(figsize=(10, 5))
参考网址:https://www.jb51.net/article/140719.htm
2. 去除plt画图四周的空白区域
2.1 方法一
实验后发现此方法会将坐标轴去掉。
plt.gca().xaxis.set_major_locator(plt.NullLocator())
plt.gca().yaxis.set_major_locator(plt.NullLocator())
plt.subplots_adjust(top=1,bottom=0,left=0,right=1,hspace=0,wspace=0)
参考网址:https://blog.csdn.net/xull88619814/article/details/82052894
2.2 方法二
实验后发现此方法不错。
plt.savefig('hah.png',bbox_inches='tight',dpi=fig.dpi,pad_inches=0.0)
参考网址:https://blog.csdn.net/cuotiaowei2543/article/details/83623655
还有一参考网址未验证:https://blog.csdn.net/raby_gyl/article/details/80337550