コード例 #1
0
ファイル: wordimg.py プロジェクト: YIKAILucas/DataAnalysis
 def get_word(name=NAME, value=VALUE):
     path = sys.path[1]
     maskimg = plt.imread(path + '/Image/brunomars.jpeg')
     wc = WordCloud(width=600, height=600, background_color='white')
     wc.use_theme('dark')
     wc.add("词云图", name, value, shape="circle", word_gap=20, word_size_range=None, rotate_step=45, mask=maskimg)
     return wc
コード例 #2
0
class PyechatesWordCloud(object):
    def __init__(self,
                 word_list,
                 width=1300,
                 height=620,
                 name="",
                 shape="circle",
                 word_gap=20,
                 word_size_range=[12, 60],
                 theme="dark"):
        value_list = []
        for word in word_list:
            value_list.append(random.randint(10, 100))
        self.wordcloud = WordCloud(width, height)
        self.wordcloud.add(name, word_list, value_list, word_size_range)
        self.wordcloud.use_theme(theme)

    def render(self):
        image_path = "images/pyechartsWordCloud.png"
        self.wordcloud.render(path=image_path)
        return image_path