'UnsetValueError while plotting WordCloud using bokeh package
Here is the code I am using to generate a word cloud using bokeh library in python. The current python, bokeh, and bokeh_wordcloud2 version(s) are 3.7.6, 1.4.0, and 0.9 respectively.
from bokeh.io import show
from bokeh.models import ColumnDataSource
from bokeh_wordcloud2 import WordCloud2
data = [['susan',6], ['tom',3], ['frankie',8],
['roger',7], ['amy',9], ['nicole',10],
['joran',5], ['mark',4], ['brianne',7],
['michael',8], ['greg',4], ['adrian',6], ['drew',9]]
names,weights = zip(*data)
test1 = ColumnDataSource({'names':names,'weights':weights})
wordcloud = WordCloud2(source=test1,wordCol="names",sizeCol="weights",color="pink")
show(wordcloud)
Error
---------------------------------------------------------------------------
UnsetValueError Traceback (most recent call last)
<ipython-input-1-b167ef5d6ae0> in <module>
14 # we will specify just "blue" for the color
15 wordcloud = WordCloud2(source=test1,wordCol="names",sizeCol="weights",color="pink")
---> 16 show(wordcloud)
~\AppData\Roaming\Python\Python38\site-packages\bokeh\io\showing.py in show(obj, browser, new, notebook_handle, notebook_url, **kw)
137 return run_notebook_hook(state.notebook_type, 'app', obj, state, notebook_url, **kw)
138
--> 139 return _show_with_state(obj, state, browser, new, notebook_handle=notebook_handle)
140
141 #-----------------------------------------------------------------------------
~\AppData\Roaming\Python\Python38\site-packages\bokeh\core\property\descriptors.py in __get__(self, obj, owner)
502 return value
503 else:
--> 504 raise UnsetValueError(f"{obj}.{self.name} doesn't have a value set")
505 elif owner is not None:
506 return self
UnsetValueError: WordCloud2(id='1002', ...).click doesn't have a value set
I see that click is expecting a JS Instance for input ==> click: expected an instance of type CustomJS. Please suggest if there is a fix/workaround for the above-mentioned error.
Also, suggest if there is an easy way to generate word clouds using bokeh?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
