我想通了,如果有人感兴趣的话;您需要获取单独的频率分布并将它们输入到字典中,其中包含所有 FreqDist 共有的键和表示每个 FreqDist 结果的值元组,然后您需要绘制每个 FreqDist 的值并设置键作为 xvalues,以相同的顺序将它们拉出。
win = FreqDist([tag for word, tag in win]) # 'win', 'draw', 'lose' and 'mixed' are already POS tagged (lists of tuples ('the', 'DT'))
draw = FreqDist([tag for word, tag in draw])
lose = FreqDist([tag for word, tag in lose])
mixed = FreqDist([tag for word, tag in mixed])
POS = [item for item in win] # list of common keys
results = {}
for key in POS:
results[key] = tuple([win[key], draw[key], lose[key], mixed[key]]) # one key, tuple of values for each FreqDist (in order)
win_counts = [results[item][0] for item in results]
draw_counts = [results[item][1] for item in results]
lose_counts = [results[item][2] for item in results]
mixed_counts = [results[item][3] for item in results]
display = [item for item in results] # over-cautious, same as POS above
plt.plot(win_counts, color='green', label="win") # need to 'import pyplot as plt'
plt.plot(draw_counts, color='blue', label="draw")
plt.plot(lose_counts, color='red', label="lose")
plt.plot(mixed_counts, color='turquoise', label="mixed")
plt.gca().grid(True)
plt.xticks(np.arange(0, len(display), 1), display, rotation=45) # will put keys as x values
plt.xlabel("Parts of Speech")
plt.ylabel("Counts per 10,000 tweets")
plt.suptitle("Part of Speech Distribution across Pre-Win, Pre-Loss and Pre-Draw Corpora")
plt.legend(loc="upper right")
plt.show()