當我繪製數據的列表(爲freqlist):龜背圖形繪製
[0.09090909090909091,0.0,0.0,0.09090909090909091,0.18181818181818182,0.0,0.0,0.0,0.045454545454545456,0.0,0.0,0.0,0.0, 0.045454545454545456,0.045454545454545456,0.045454545454545456,0.045454545454545456,0.18181818181818182,0.045454545454545456,0.09090909090909091,0.045454545454545456,0.0,0.045454545454545456,0.0,0.0,0.0]
當我嘗試填充顏色的吧,只有一半吧得到填補,類似於一個直角三角形。此外,我不知道如何標記x和y軸以使x軸上的字母a-z代表每個小數點。 y軸上的0.0 - max(freqList)的頻率將根據每個十進制數字遞增。我知道我必須使用t.write(),但我不知道在哪裏把它
def letterFreqPlot(freqList):
border = 5
t = turtle.Turtle()
t.pensize(3)
screen = t.getscreen()
maxheight = max(freqList)
numbers = len(freqList)
screen.setworldcoordinates(0-border,-.05,numbers+1,maxheight)
t.goto(0,0)
t.speed(0)
t.lt(90)
t.fd(maxheight)
t.fd(-maxheight)
t.right(90)
for item in freqList:
t.fillcolor("blue")
for dist in [1, item, 1, item]:
t.begin_fill()
t.fd(dist)
t.lt(90)
t.fd(1)
t.end_fill()