python – 从打开窗口停止matplotlib图(未调用plt.show())
发布时间:2020-12-20 13:11:13 所属栏目:Python 来源:网络整理
导读:我正在使用以下代码创建一个绘图,并将其保存到路径中.但是,该图打开了一个新窗口,没有显式调用plt.show().有谁知道如何阻止窗口打开? arr1 = np.random.rand(150,500)arr2 = np.random.rand(150,500)fig = plt.figure()a=fig.add_subplot(1,2,1)imgplot = p
我正在使用以下代码创建一个绘图,并将其保存到路径中.但是,该图打开了一个新窗口,没有显式调用plt.show().有谁知道如何阻止窗口打开?
arr1 = np.random.rand(150,500) arr2 = np.random.rand(150,500) fig = plt.figure() a=fig.add_subplot(1,2,1) imgplot = plt.imshow(arr1) a.set_title('Image 1') a.xaxis.set_visible(False) a.yaxis.set_visible(False) a=fig.add_subplot(2,1) imgplot = plt.imshow(arr2) a.set_title('Image 2') a.xaxis.set_visible(False) a.yaxis.set_visible(False) plt.savefig('C:/Users/.../fig.png',bbox_inches='tight') 解决方法
尝试%pylab内联 – 然后程序将不会创建另一个窗口
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |