【问题标题】:Set y a-xis to trange from 0 to 100 in matplotlib [duplicate]在matplotlib中将y轴设置为从0到100 [重复]
【发布时间】:2020-10-12 05:51:41
【问题描述】:

如何将我的 y 轴设置在 0 到 100 之间?这是我的代码:

fig, ax = plt.subplots()
plt.plot(history.history['accuracy'], marker="*", label='Train accuracy', color='blue')
plt.plot(history.history['val_accuracy'], marker="o", label='Test accuracy', color='red')
plt.title('Plot' )
plt.ylabel('yaxis')
plt.xlabel('xaxis')
plt.legend(loc='best')
plt.show()

【问题讨论】:

    标签: python python-3.x matplotlib


    【解决方案1】:

    一种方法是使用ylim,如:

    ...
    plt.xlabel('xaxis')
    plt.legend(loc='best')
    plt.ylim(0,100).         # <== This is the relevant piece. 
    plt.show()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-30
      • 1970-01-01
      • 2011-04-16
      相关资源
      最近更新 更多