I try to generate two separate wordcloud for positive and negative. However, when I use savefig it only save the last figure. The last figure is negative sentiment.
TEXT_COLUMN = 'pre_process'
TARGET_COLUMN = 'label'
# visualize the data on a WordCloud
def visualize(label):
words = ''
for msg in data[data[TARGET_COLUMN] == label][TEXT_COLUMN]:
msg = msg.lower()
words += msg + ' '
wordcloud = WordCloud(width=600, height=600).generate(words)
plt.imshow(wordcloud)
plt.axis('off')
plt.title('Wordcloud')
plt.savefig('static/airasia_negcloud.png',transparent=True)
plt.show()
plt.clf()
# display wordcloud
visualize(1)
visualize(0)
Here is my wordcloud coding. When I visualize it, it display correctly on PyCharm but in the folder, one is blank image which is suppose to be positive wordcloud and another one is negative worcloud.