0

我要保存的图表是由 OPTUNA 包制作的。当我 savefig() 时,他们都没有保存图表。而 plt.show() 正确显示我的图表

# Main
if __name__ == '__main__':
    
    import optuna
    #from optuna_custom_visualization import *
    import matplotlib.pyplot as plt


    study = optuna.create_study()  # Create a new study.
    study.optimize(Objective(), n_trials=5)  # Invoke optimization of the objective function.

    plot_slice = optuna.visualization.plot_slice(study, target_name = 'Test Accuracy')
    plt.savefig('Plot2.png')
    
    plot_history = optuna.visualization.plot_optimization_history(study)
    
    #plot_history = custom_plot_optimization_history(study)
    
    plt.title('')
    y = plt.ylabel('Test Accuracy')
    plt.legend(handles = [y], labels = ['Accuracy'])
    #plt.axvline(50,ls='--')
    plt.axvline(454, ls='dashed')
    plt.xlim(-20,520)
    plt.savefig('Plot1.png')

4

0 回答 0