我想将wordcloud图片返回给用户,我这样做了,但是图片周围出现了白框
我的烧瓶代码
wordcloud = WordCloud(max_font_size=50, max_words=100, background_color="#2c3446", mode="RGBA").generate(' '.join(cleannew[0]))
img = io.BytesIO()
plt.imshow(wordcloud, interpolation="bilinear")
plt.axis("off")
plt.savefig(img, format='png', dpi=100)
img.seek(0)
graph_url = base64.b64encode(img.getvalue()).decode()
plt.close()
wordcloudgraph = 'data:image/png;base64,{}'.format(graph_url)
#and i return html file with wordcloudgraph
我的HTML代码:
<img src='{{ graph1 }}'></img>
我得到了这张图片:https://ibb.co/8B8FkMq
在我的网站中:https://ibb.co/7WXqn5q