在python中,我有以下功能來創建Mendenhall的組成特征曲線
def mendenhall(toks):
dist = nltk.FreqDist([len(w) for w in toks])
x = sorted(dist.keys())
y = [dist[i] for i in x]
return x, y
然后我使用它創建了以下圖表
x,y = mendenhall((nltk.corpus.brown.words(categories='romance')))
plt.plot(x,y)
和
x,y = mendenhall((nltk.corpus.brown.words(categories='mystery')))
plt.plot(x,y)
但是有沒有辦法把這兩個放在一個圖表上,或者它們必須分開?
uj5u.com熱心網友回復:
這是我所說的有效的存在證明:
import matplotlib.pyplot as plt
x = [1,2,3,4,5]
y1 = [6,7,8,9,10]
y2 = [7,6,5,4,3]
plt.plot(x,y1)
plt.plot(x,y2)
plt.show()
所以,在你的情況下:
x,y = mendenhall((nltk.corpus.brown.words(categories='romance')))
plt.plot(x,y)
x,y = mendenhall((nltk.corpus.brown.words(categories='mystery')))
plt.plot(x,y)
plt.show()
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/365141.html
標籤:Python matplotlib
