Bokeh: 'generator' object has no attribute 'tooltips'

import bokeh.plotting as bp
from bokeh.plotting import figure
from bokeh.models import HoverTool
bp.output_notebook()
row_selector = np.where(users_per_subreddit>5)
tbf = bp.figure(plot_width=900, plot_height=700, title=“Subreddit Map by Most Informative Dimensions”,
x_axis_label = “Dimension 0”,
y_axis_label = “Dimension 1”,
tools=“pan,wheel_zoom,box_zoom,reset,hover,previewsave”,
min_border=1)
tbf.scatter(
x = embedded_coords[:,0][row_selector],
y = embedded_coords[:,1][row_selector],
radius= np.log2(users_per_subreddit[row_selector])/6000,
source=bp.ColumnDataSource({“subreddit”: subreddits[row_selector]})
).select(HoverTool).tooltips = {"/r/":"@subreddit"}

tbf.show()

``

This snippet is giving the following error:

AttributeError                            Traceback (most recent call last)
<ipython-input-14-51346c59c121> in <module>()
      9     radius= np.log2(users_per_subreddit[row_selector])/6000,
     10     source=bp.ColumnDataSource({"subreddit": subreddits[row_selector]})
---> 11 ).select(HoverTool).tooltips = {"/r/":"@subreddit"}
     12
     13 # s1 = fig.scatter(x=x,y=y1,color='#0000ff',size=10,legend='sine')

AttributeError: 'generator' object has no attribute 'tooltips'

What to do???

Bokeh isn’t designed to support the kind of chaining you are trying to do. figure.scatter() doesn’t return the figure object but the glyph renderer that is created. So by chaining this with select you are trying to find a HoverTool within the returned renderer. I would suggest looking through this section of the user guide, which gives some good examples on how to add custom hover tools to plots.

···

On Tue, Apr 25, 2017 at 10:49 AM, Gopal Kumar [email protected] wrote:

import bokeh.plotting as bp
from bokeh.plotting import figure
from bokeh.models import HoverTool
bp.output_notebook()
row_selector = np.where(users_per_subreddit>5)
tbf = bp.figure(plot_width=900, plot_height=700, title=“Subreddit Map by Most Informative Dimensions”,
x_axis_label = “Dimension 0”,
y_axis_label = “Dimension 1”,
tools=“pan,wheel_zoom,box_zoom,reset,hover,previewsave”,
min_border=1)
tbf.scatter(
x = embedded_coords[:,0][row_selector],
y = embedded_coords[:,1][row_selector],
radius= np.log2(users_per_subreddit[row_selector])/6000,
source=bp.ColumnDataSource({“subreddit”: subreddits[row_selector]})
).select(HoverTool).tooltips = {"/r/":"@subreddit"}

tbf.show()

``

This snippet is giving the following error:

AttributeError                            Traceback (most recent call last)
<ipython-input-14-51346c59c121> in <module>()
      9     radius= np.log2(users_per_subreddit[row_selector])/6000,
     10     source=bp.ColumnDataSource({"subreddit": subreddits[row_selector]})
---> 11 ).select(HoverTool).tooltips = {"/r/":"@subreddit"}
     12
     13 # s1 = fig.scatter(x=x,y=y1,color='#0000ff',size=10,legend='sine')

AttributeError: 'generator' object has no attribute 'tooltips'

What to do???

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/36dbd452-4582-4c33-91d5-ba2062cb74b8%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

It's probably also worth mentioning that .select returns a generator. If you want to get a real list out of it, you'd need to do "list(obj.select(...))" or else iterate over the generator in a loop. If you just want to find the "first" object back, there is also a .select_one(...) method that will return an actual object, not a generator.

Thanks,

Bryan

···

On Apr 27, 2017, at 22:52, Tyler Nickerson <[email protected]> wrote:

Bokeh isn't designed to support the kind of chaining you are trying to do. figure.scatter() doesn't return the figure object but the glyph renderer that is created. So by chaining this with select you are trying to find a HoverTool within the returned renderer. I would suggest looking through this section of the user guide, which gives some good examples on how to add custom hover tools to plots.

On Tue, Apr 25, 2017 at 10:49 AM, Gopal Kumar <[email protected]> wrote:
import bokeh.plotting as bp
from bokeh.plotting import figure
from bokeh.models import HoverTool
bp.output_notebook()
row_selector = np.where(users_per_subreddit>5)
tbf = bp.figure(plot_width=900, plot_height=700, title="Subreddit Map by Most Informative Dimensions",
       x_axis_label = "Dimension 0",
       y_axis_label = "Dimension 1",
       tools="pan,wheel_zoom,box_zoom,reset,hover,previewsave",
       min_border=1)
tbf.scatter(
    x = embedded_coords[:,0][row_selector],
    y = embedded_coords[:,1][row_selector],
    radius= np.log2(users_per_subreddit[row_selector])/6000,
    source=bp.ColumnDataSource({"subreddit": subreddits[row_selector]})
).select(HoverTool).tooltips = {"/r/":"@subreddit"}

tbf.show()

This snippet is giving the following error:

AttributeError
                            Traceback (most recent call last)

<ipython-input-14-51346c59c121> in <module>()
      9 radius= np.log2(users_per_subreddit[row_selector])/6000,
     10 source=bp.ColumnDataSource({"subreddit": subreddits[row_selector]})
---> 11
).select(HoverTool).tooltips = {"/r/":"@subreddit"}

     12

     13 # s1 = fig.scatter(x=x,y=y1,color='#0000ff',size=10,legend='sine')

AttributeError: 'generator' object has no attribute 'tooltips'

What to do???

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/36dbd452-4582-4c33-91d5-ba2062cb74b8%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/CAAd1xFS3zDVJC-cCu8r2yaO%2B77a%3D2xKanhFjivyU7Eiw_UGRFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.