美文网首页
记录一下hackerthon遇到的坑-持更直到hackertho

记录一下hackerthon遇到的坑-持更直到hackertho

作者: 渡笃狼 | 来源:发表于2017-11-16 00:08 被阅读11次
    1. 尝试使用wordcloud画图,结果图像怎么也出不来 QQ
      Sample code如下:
    from wordcloud import WordCloud
    import matplotlib.pyplot as plt
    
    wordcloud = WordCloud(
        font_path='simhei.ttf', 
        background_color="black"
    )
    
    words = fSegStat.set_index('segment').to_dict()
    
    wordcloud.fit_words(words['count'])
    
    plt.axis('off')
    
    plt.imshow(wordcloud)
    
    plt.close()
    

    解决方法:1. 把生成的词云图片保存到本地

    plt.savefig('wordcloud.png')
    
    1. 在close plot之前,使用show()方法
    plt.show()
    

    相关文章

      网友评论

          本文标题:记录一下hackerthon遇到的坑-持更直到hackertho

          本文链接:https://www.haomeiwen.com/subject/raskvxtx.html