python画图问题:vscode运行结果有多张图,但是关掉一张后才显示下一张图

python画图

在每张图前面加上plt.figure(),且最后只有一个输出plt.show(),这样就可以达到一次把多张运行图全部显示的目的。

plt.figure()
plt.plot(iteration, matrix_x[0], color='red')
plt.plot(iteration, matrix_x[1], color='green')
plt.plot(iteration, matrix_x[2], color='blue')
plt.plot(iteration, matrix_x[3], color='cyan')
plt.plot(iteration, matrix_x[4], color='yellow')
plt.xlabel('time')
plt.ylabel('state information')
#plt.show()


plt.figure()
plt.plot(iteration, new_matrix_x[0], color='red')
plt.plot(iteration, new_matrix_x[1], color='green')
plt.plot(iteration, new_matrix_x[2], color='blue')
plt.plot(iteration, new_matrix_x[3], color='cyan')
plt.plot(iteration, new_matrix_x[4], color='yellow')
plt.xlabel('time')
plt.ylabel('state information')
plt.show()
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值