1

我想绘制一个直方图,通过随机手在 x 次试验中找到多少个带有 2、3、4、5、6 或 7 个字符的拼字游戏单词。

直方图在 x 和 y 轴上应具有以下值:MS 油漆示例

我有一个结果列表:[0.33, 0.42, 0.33, 1.09, 0.3, 0.0],第一个值意味着我在 100 次试验中平均每手有 0.33 个 2 字符的单词。第二个值是 3 个字符的单词,依此类推。

目前我有这样的事情:从python保存的图像

在 x 轴上有平均字数,y 轴包含值的数量(两个值相同,这就是为什么第三行打印值为 2)。我不知道代码应该是什么样子。

4

1 回答 1

2

解决了pylab.bar()

pylab.figure()
pylab.bar(xaxis, plot_list, align='center', color='green')
pylab.title('Amount of scrabble words, possible to phrase from a random hand (100 trials)')
pylab.xlabel('Length of words')
pylab.ylabel('Average amount of words')
pylab.show()

这是解决方案的样子:

于 2013-04-24T07:13:34.827 回答