How to produce a wordcloud in python with consistent word positioning?

Viewed 752

I am trying to create an animated word cloud in Python (3.7) using the wordcloud package.

The problem is that the words change position every run (understandably). Is there way to keep the positions the same, or better still make an animated wordcloud in Python?

My idea was to run it multiple times with increasingly larger sections of my text corpus until complete. These snapshots could then be stitched together into a GIF.

for i in range(0,int(len(topic3)/5)):
    wordcloud = WordCloud(width=1600, height=800, max_words=50).generate(str(topic9["Verbatims"].iloc[0:i*5]))
    # Open a plot of the generated image.
    plt.figure( figsize=(20,10), facecolor='k')
    plt.imshow(wordcloud)
    plt.axis("off")
    plt.tight_layout(pad=0)
#     plt.show()
    name = "word_plot_" + str(i)
    plt.savefig(name)
0 Answers
Related