Python Pylab直方图显示x轴上的所有箱子

Python Pylab直方图显示x轴上的所有箱子,python,graph,histogram,matplotlib,Python,Graph,Histogram,Matplotlib,我正在编写一个小型python程序来进行频率分析,我想知道如何让所有的容器显示在x轴上,而不是以5为增量。还有一种方法可以在x轴上显示类似“a”的字符串值而不是数字吗 代码: 谢谢, 亚历克斯。你可以用 当你说要显示的所有箱子时,你是指所有的记号标签吗?是的,只是我想要的沿x轴的值。 print "Please specify the file to analyse." FileContents = FileToIntArray() # Count letter occurances in f

我正在编写一个小型python程序来进行频率分析,我想知道如何让所有的容器显示在x轴上,而不是以5为增量。还有一种方法可以在x轴上显示类似“a”的字符串值而不是数字吗

代码:

谢谢, 亚历克斯。

你可以用


当你说要显示的所有箱子时,你是指所有的记号标签吗?是的,只是我想要的沿x轴的值。
print "Please specify the file to analyse."
FileContents = FileToIntArray()

# Count letter occurances in file
letterCounts = zeros(26).tolist()
for x in FileContents:
    i = AlphaNum.index(x)
    letterCounts[i] = letterCounts[i] + 1

# Plot histogram of counts
print "" # Newline
title("Absolute Frequencies")
xlabel("Letters A-B (Where A = 0 & Z = 25)")
ylabel("Letter Occurences")
hist(letterCounts, bins=AlphaNum)
show()
xticks(arange(len(AlphaNum)),AlphaNum)