Reputation: 9484
I have list of number
scores = [0.4126984126984127,
0.9841269841269841,
0.9841269841269841,
0.3333333333333333,
0.6825396825396826,
0.7301587301587301,
0.9841269841269841,
0.4603174603174603,
1.0]
names = ["Nearest Neighbors", "Linear SVM", "RBF SVM", "Gaussian Process",
"Decision Tree", "Random Forest", "Neural Net",
"AdaBoost",
"Naive Bayes"
]
I would like to plot the y-axis the scores and x-axis names of them then.
import matplotlib.pyplot as plt
fig, axs = plt.subplots()
axs.plot(scores)
axs.set_xlabel("classifier names")
axs.set_ylabel("Score")
axs.set_xticklabels(names, rotation=90)
I got warning and the x-axis is shift by one and I lost it!
In the picture nearest neighbor is lost and the rest of them are shifted
Question
How to solve this error?
Upvotes: 1
Views: 369
Reputation: 9484
matplotlib does not automatically calculate xticks. I have to put it myself
axs.set_xticks([i for i in range(9)])
Upvotes: 1