【问题标题】:The xlabel and ylabel are not shown when I run this this code运行此代码时未显示 xlabel 和 ylabel
【发布时间】:2019-12-23 14:35:32
【问题描述】:

当我使用此代码绘制图表时,我得到了图表,但未显示 x 和 y 标签。

plt.figure(1)
plt.plot(history.history["loss"], "b", label="Mean Square Error of training")
plt.plot(history.history["val_loss"], "g", label="Mean Square Error of validation")
plt.legend()
plt.xlabel("Epoche")
plt.ylabel("Mean Square Error")
plt.xlim(0,200)
plt.show()
plt.savefig(r"C:\Users\aheidari\Dropbox\Dissertation\primary hot water use prediction\Diagrams\UnivariateTrainingerror.png", dpi=1200)

【问题讨论】:

    标签: python matplotlib plot


    【解决方案1】:

    您可能只需要删除历史记录。历史之前:

    import matplotlib.pyplot as plt
    import pandas as pd
    
    history = pd.DataFrame([[1,2],[3,4],[5,6]],columns=['loss','val_loss'])
    
    plt.plot(history["loss"], "b", label="Mean Square Error of training")
    plt.plot(history["val_loss"], "g", label="Mean Square Error of validation")
    plt.legend()
    plt.xlabel("Epoche")
    plt.ylabel("Mean Square Error")
    plt.show()
    

    【讨论】:

      猜你喜欢
      • 2020-11-08
      • 2019-12-17
      • 1970-01-01
      • 2017-07-02
      • 1970-01-01
      • 2018-12-09
      • 2014-06-26
      • 2014-06-23
      • 2013-04-15
      相关资源
      最近更新 更多