Ejemplo n.º 1
0
def genpic():
    db = DB()
    table_name = "com_info"
    res = db.query(table_name)
    fig = plt.figure(figsize=(15, 15))
    fig.set(alpha=0.5)
    df = pd.DataFrame(res)
    print(df)
    plt.subplot2grid((2, 2), (0, 0))
    df.years.value_counts().plot(kind='bar')
    print(df.years.value_counts())
    plt.subplot2grid((2, 2), (0, 1))
    df.comscale.value_counts().plot(kind='bar')
    plt.subplot2grid((2, 2), (1, 0))
    df.education.value_counts().plot(kind='bar')
    plt.subplot2grid((2, 2), (1, 1))
    df.comdomain.value_counts().plot(kind='bar')
    plt.savefig('counts.jpg')
    plt.show()
Ejemplo n.º 2
0
        if isfile(background_picture_filename):
            prefix = file.split('.')[0]

            bimg = imread(background_picture_filename)
            wordcloud = WordCloud(font_path=font_filename,
                                  background_color='white',
                                  mask=bimg,
                                  max_font_size=600,
                                  random_state=100)
            wordcloud = wordcloud.fit_words(
                dict(words_stat.head(4000).itertuples(index=False)))

            bimgColors = ImageColorGenerator(bimg)
            wordcloud.recolor(color_func=bimgColors)

            plt.imshow(wordcloud)
            plt.axis('off')
            plt.show()
            wordcloud.to_file("result.png")


if __name__ == '__main__':
    db = DB()
    table_name = "com_info"
    res = db.query(table_name)
    content = ""
    for info in res:
        print(info['moredetail'])
        content = content + " " + info['moredetail']
    main(content)