wordcloud-1.9.1开始无法在python3.6和海龟编辑器内正常使用,特做了一个whl 提供给python3.6使用。
另外我自己使用Python3.8 ,因此wordcloud-1.9.2-cp36-cp36-win_amd64.whl 和wordcloud-1.9.3-cp38-cp38-win_amd64.whl,词云图上有前20个单词的频次。
使用效果如图:
修改代码wordcloud.py
def to_image(self):
self._check_generated()
if self.mask is not None:
width = self.mask.shape[1]
height = self.mask.shape[0]
else:
height, width = self.height, self.width
x=int(width * self.scale)
y=int(height * self.scale)
#高和宽280、200,多出的像素用于存放单词频次
img = Image.new(self.mode, (x+280,
y+220),
self.background_color)
draw = ImageDraw.Draw(img)
jishu=-1
words1=''
for (word, c