假设我有一个字符串,我想把它变成一个单词cloud,比如:
from wordcloud import WordCloud
import matplotlib.pyplot as plt
teststring = 'hi this is a test test test test test string for a word cloud'
wordcloud = WordCloud(width=1000, height=1000, margin=0, background_color='white',
collocations=False).generate(teststring)
plt.imshow(wordcloud)
我还做了一个有几个标签的bokeh标签对象
from bokeh.plotting import figure, output_file, show
from bokeh.models.widgets import Panel, Tabs
output_file('stackoverflow.html')
p1 = figure()
p1.line(x=range(5), y=range(5))
tab1 = Panel(child=p1, title="Line plot")
tabs = Tabs(tabs=[tab1])
show(tabs)
如何将wordcloud的图形添加到tab2中以显示在面板中?
我看了很多链接(比如),但都没用。我发现的关闭是在这里:
How do I work with images in Bokeh (Python)
,但要让它起作用,我似乎必须中间保存wordcloud(实际上我有大约25个)。这真的是必要的吗,或者我可以立即在bokeh中显示wordcloud吗?
提前谢谢!