python中是否有plt.show(0)的替代方法,plt.show(0)不再起作用,现在显示错误?

时间:2019-07-17 11:31:08

标签: python matplotlib

我正在运行一个循环,并在每个循环中绘制结果,之前我使用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)

文件253行,显示为“ C:\ Users \ n0762538 \ AppData \ Local \ Continuum \ anaconda3 \ lib \ site-packages \ matplotlib \ pyplot.py”

返回_show(* args,** kw)

TypeError:调用()接受1个位置参数,但给出了2个

0 个答案:

没有答案