我正在尝试绘制线x对数刻度,但是尽管刻度正确,但第一个点没有显示。x == 0的值为1.57,x == 10 ^(-8)的值为0.4。
我该如何纠正情节?
plt.plot(lambdas, errors, "-b", label = 'Test')
plt.plot(lambdas,errors_train, "-r", label = 'Train')
plt.xscale('log')
plt.legend(loc="upper left")
plt.xlabel('ln lambda')
plt.ylabel('Root Mean Squared Error')
plt.savefig("1.png")
plt.show()
您可以使用symlog
比例尺并根据需要设置线性阈值(最小值,比例尺将变为线性阈值):
import matplotlib.pyplot as plt
plt.plot([0, 1e-8, 1e-7, .1], [1.6, .4, .3, .4])
plt.xscale('symlog', linthresh=1e-8)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句