python - python 中是否有 plt.show(0) 的替代方法, plt.show(0) 不再起作用它现在显示错误?
问题描述
我正在运行一个循环,并在每个循环中绘制结果,之前我使用 plt.show(0) 冻结图形,并且在所有循环结束时,所有子图都出现在一个图形上。但是, plt.show(0) 现在显示错误。
我已经尝试过 plt.ioff() 和 plt.pause(0.01) 但它在新图形上单独绘制子图。
trials = 6
c = 2
r = int(trials / c)
for i in range(1, trials + 1):
print('Trial {} of {}'.format(i, trials))
# train NN
weights, bias, avg_cost_func, m_weights, memory, trained_model, training_data = train_nn(nn_structure, mm_structure, inputs, outputs, window_size, horizon, iter_num, eta, momentum)
# FIGURE 1: plot the ROC curve for training data
fig1 = plt.figure(1, figsize=(10, 40))
fig1.suptitle('ROC curve for inhospital mortality classifier training data')
# subplot
fig1.add_subplot(r, c, i).plot(avg_cost_func)
plt.title((('Trail {} of {}'.format(i, trials)), str(np.round(np.average(avg_cost_func), 5))))
plt.ylabel('Average J')
plt.xlabel('Iteration number')
plt.pause(0.01)
plt.show(0)
plt.subplots_adjust(wspace=0.5, hspace=1.5)
plt.show()
文件“filename.py”,第 451 行,在 plt.show(0)
文件“C:\Users\n0762538\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\pyplot.py”,第 253 行,显示
返回 _show(*args, **kw)
TypeError: call () 接受 1 个位置参数,但给出了 2 个
解决方案
推荐阅读
- java - OpenPDF - 一个单元格中的多行
- python - 在 Flask 页面上显示的 Matplotlib 创建的热图 SVG 中添加每个框的链接
- python - “IndexError:列表索引超出范围”错误
- r - 从 r 中的数据集中删除尾随的 0 和 1
- python - 从 df 在 Python 中创建特征表
- node.js - 解决 CloudFlare 下自定义域上的服务器请求中断错误
- python - 为什么我的 MongoDB 查询比 python 慢?
- if-statement - 在 Rust 中使用 if 语句时的不同函数类型
- python - 如何让 django 表单接受具有初始值的禁用表单
- python-3.x - Pystan 安装成功但无法编译