1
我正在與python3中的wordcloud模塊一起工作,並試圖保存一個只能給我形象的wordcloud,沒有任何圍繞雲的空格。我嘗試了很多在stackexchange中提到的ticks,但他們沒有用。下面是我的默認代碼,它可以消除左側和右側的空白而不是頂部和底部的空白。如果我將ax = plt.axes([0,0,1,1])中的另外兩個值設置爲0,那麼我會得到一個空的圖像。python3中沒有任何空格的Python wordcloud
wordcloud = WordCloud(font_path=None, width = 1500, height=500,
max_words=200, stopwords=None, background_color='whitesmoke', max_font_size=None, font_step=1, mode='RGB',
collocations=True, colormap=None, normalize_plurals=True).generate(filteredText)
import matplotlib.pyplot as plt
fig = plt.figure()
ax = plt.axes([0,0,1,1])
plt.imshow(wordcloud, interpolation="nearest")
plt.axis('off')
plt.savefig('fig.png', figsize = (1500,500), dpi=300)
請問有人能幫我解決這個問題嗎?
非常感謝你@ImportanceOfBeingErnest這只是我想要的一切。我正在使用scipy.misc import imsave imsave(__ file __ +'。png',wc)now,它工作正常。 –