国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python 詞云

2019-11-08 18:36:02
字體:
來源:轉載
供稿:網友
# -*- coding: utf-8 -*-""""Masked Wordcloud================Using a mask you can generate wordclouds in arbitrary shapes."""from os import pathfrom PIL import Imageimport numpy as npimport matplotlib.pyplot as pltfrom wordcloud import WordCloud, STOPWORDSd = path.dirname(__file__)# Read the whole text.text = open(path.join(d, 'hua.txt')).read()# read the mask image# taken from# http://www.stencilry.org/stencils/movies/alice%20in%20wonderland/255fk.jpgalice_mask = np.array(Image.open(path.join(d, "bb.png")))wc = WordCloud(background_color="white", max_words=2000, mask=alice_mask,               stopwords=STOPWORDS.add("said"))# generate word cloudwc.generate(text)# store to filewc.to_file(path.join(d, "bb.png"))# showplt.imshow(wc)plt.axis("off")plt.figure()plt.imshow(alice_mask, cmap=plt.cm.gray)plt.axis("off")plt.show()
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 安达市| 馆陶县| 海兴县| 奉节县| 绵竹市| 廉江市| 天柱县| 中江县| 涿鹿县| 丹东市| 连云港市| 靖江市| 达孜县| 安化县| 临清市| 庆安县| 洛隆县| 嘉荫县| 舟曲县| 渭源县| 新龙县| 临朐县| 岳阳市| 藁城市| 靖江市| 邵武市| 利川市| 靖边县| 尉犁县| 吴桥县| 博野县| 永和县| 无极县| 承德县| 都江堰市| 靖宇县| 洛宁县| 芜湖县| 甘肃省| 海林市| 北票市|