Suppose I have a string for which I want to make a word cloud, like so:
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)
Furthemore I have made a bokeh Tabs object with a few tabs
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)
How can I add the figure of the wordcloud to a tab2, to show in the panel?
I've looked at many links (such as), but couldn't get it to work. The closes I found was here: How do I work with images in Bokeh (Python), but for this to work, it seems I have to save the wordcloud intermediately (in fact I have ~25 of them). Is that really necessary, or can I also immediately show the wordcloud in bokeh?
Thanks in advance!