0
我想使用matplotlib構建圖表,但不幸的是我無法弄清楚如何標記y軸。我想從0.1到1.0開始,並且有0.1的差異。 我設法設置其極限是這樣的:Matplotlib標籤y軸
import numpy as np
import matplotlib.pyplot as plt
N = 10
menMeans = (0.58836, 0.6224, 0.73047, 0.79147, 0.79284, 0.79264, 0.79922, 0.82043, 0.81834, 0.74767)
ind = np.arange(N) # the x locations for the groups
width = 0.20 # the width of the bars
fig, ax = plt.subplots()
rects1 = ax.bar(ind, menMeans, width, color='g')
womenMeans = (0.61139, 0.62270, 0.63627, 0.75868, 0.73087, 0.73128, 0.77205, 0.59866, 0.59385, 0.59891)
rects2 = ax.bar(ind+width, womenMeans, width, color='b')
# add some
ax.set_ylabel('Accuracy')
ax.set_xticks(ind+width)
ax.set_xticklabels(('Naive', 'Norm', 'Unigrams \n(FreqDist)', 'Unigrams(LLR)', 'Unigrams (LLR)\n Bigrams', 'Unigrams (LLR)\n Bigrams (CHI)',
'Unigrams (LLR)\n Bigrams (LLR)', 'Features', 'POS', 'LDA'))
ax.legend((rects1[0], rects2[0]), ('Naive Bayes', 'Maximum Entropy'))
ax.set_ylim(0, 1)
plt.grid(axis='y', linestyle='-')
plt.show()
但在y軸上的數字顯示只用0.2的區別。任何解決方案?謝謝!