The data of my figure is not shown in python. Only shows the axis This is my code:
import matplotlib.pyplot as plt
lambdaarray = [[0. ,0.1 ,0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., ]]
validationSetAccurary = [[70.16666667 ,70.17647059 ,70.48039216 ,70.82352941 ,70.43137255 ,69.59803922,69.44117647 ,69.16666667, 69.26470588, 68.94117647, 68.60784314]]
plt.figure()
plt.plot(lambdaarray, validationSetAccurary)
plt.xlabel('lambdavalue')
plt.ylabel('Accuracy')
plt.show()
CodePudding user response:
Replace:
plt.plot(lambdaarray, validationSetAccurary)
with:
plt.plot(lambdaarray[0], validationSetAccurary[0])
CodePudding user response:
Can you try the following:
import matplotlib.pyplot as plt
lambdaarray = [0. ,0.1 ,0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., ]
validationSetAccurary = [70.16666667 ,70.17647059 ,70.48039216 ,70.82352941 ,70.43137255 ,69.59803922,69.44117647 ,69.16666667, 69.26470588, 68.94117647, 68.60784314]
plt.figure()
plt.plot(lambdaarray, validationSetAccurary)
plt.xlabel('lambdavalue')
plt.ylabel('Accuracy')
plt.show()
You were passing a 2D
array, you need to pass a 1D
array.