Unable to add tabs when using glyph add

I am trying to add tabs to my bokeh figure and I am following the example code on the website. However, my code uses glyph to add to the figure and when I use that to add to a panel, I don’t see anything on the graph. Here is my code:

my_time = [1,2,3,4,5,6,7,8,9]
estimated_results = [1,2,3,4,5,6,7,8,9]
# arrange in data source
src = ColumnDataSource(data= {
    'time': my_time,
    'level': estimated_results,
})

# hover tooltip
TOOLTIPS = [
("Level", "@level"),
]

# create figure
p1 = figure(title="Replay",
    x_axis_label = 'Time',
    toolbar_location="above",
    sizing_mode='stretch_both',
    tooltips=TOOLTIPS)

# create individual glyphs
glyph_level = Line(x='time', y='level',
    line_color="#1F77B4",
    line_width=2,
    )

# add to figure. create legends
renderer_level = p1.add_glyph(src, glyph_level)
tab1 = Panel(child=p1, title="Level")
li1 = LegendItem(label='Level', renderers=[renderer_level])
legend = Legend(items=[li1], location='top_right')
p1.add_layout(legend)
tabs = Tabs(tabs=[ tab1])
p1.legend.click_policy="hide"

# display plot
show(tabs)

``

What do I need to change to display the graph correctly?

Hi,

As I replied elsewhere, this is simply a bug with current versions of Bokeh. For now your only options are (again):

* don't use responsive sizing modes (i.e. "stretch_both") together with tabs

* don't use Bokeh layouts at all (e.g. use bokeh.embed.components to template Bokeh plots into your your own template with some outside, non-Bokeh tab widget)

Thanks,

Bryan

···

On Oct 3, 2018, at 09:03, rookie <[email protected]> wrote:

I am trying to add tabs to my bokeh figure and I am following the example code on the website. However, my code uses glyph to add to the figure and when I use that to add to a panel, I don't see anything on the graph. Here is my code:

my_time = [1,2,3,4,5,6,7,8,9]
estimated_results = [1,2,3,4,5,6,7,8,9]
# arrange in data source
src = ColumnDataSource(data= {
    'time': my_time,
    'level': estimated_results,
})

# hover tooltip
TOOLTIPS = [
("Level", "@level"),
]

# create figure
p1 = figure(title="Replay",
    x_axis_label = 'Time',
    toolbar_location="above",
    sizing_mode='stretch_both',
    tooltips=TOOLTIPS)

# create individual glyphs
glyph_level = Line(x='time', y='level',
    line_color="#1F77B4",
    line_width=2,
    )

# add to figure. create legends
renderer_level = p1.add_glyph(src, glyph_level)
tab1 = Panel(child=p1, title="Level")
li1 = LegendItem(label='Level', renderers=[renderer_level])
legend = Legend(items=[li1], location='top_right')
p1.add_layout(legend)
tabs = Tabs(tabs=[ tab1])
p1.legend.click_policy="hide"

# display plot
show(tabs)

What do I need to change to display the graph correctly?

--
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/7bb97c28-826a-4b21-b45e-cab795b31534%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks for the quick response, will try out your suggestions.

···

On Wednesday, October 3, 2018 at 9:13:36 AM UTC-7, Bryan Van de ven wrote:

Hi,

As I replied elsewhere, this is simply a bug with current versions of Bokeh. For now your only options are (again):

  • don’t use responsive sizing modes (i.e. “stretch_both”) together with tabs

  • don’t use Bokeh layouts at all (e.g. use bokeh.embed.components to template Bokeh plots into your your own template with some outside, non-Bokeh tab widget)

Thanks,

Bryan

On Oct 3, 2018, at 09:03, rookie [email protected] wrote:

I am trying to add tabs to my bokeh figure and I am following the example code on the website. However, my code uses glyph to add to the figure and when I use that to add to a panel, I don’t see anything on the graph. Here is my code:

my_time = [1,2,3,4,5,6,7,8,9]

estimated_results = [1,2,3,4,5,6,7,8,9]

arrange in data source

src = ColumnDataSource(data= {

'time': my_time,
'level': estimated_results,

})

hover tooltip

TOOLTIPS = [

(“Level”, “@level”),

]

create figure

p1 = figure(title=“Replay”,

x_axis_label = 'Time',
toolbar_location="above",
sizing_mode='stretch_both',
tooltips=TOOLTIPS)

create individual glyphs

glyph_level = Line(x=‘time’, y=‘level’,

line_color="#1F77B4",
line_width=2,
)

add to figure. create legends

renderer_level = p1.add_glyph(src, glyph_level)

tab1 = Panel(child=p1, title=“Level”)

li1 = LegendItem(label=‘Level’, renderers=[renderer_level])

legend = Legend(items=[li1], location=‘top_right’)

p1.add_layout(legend)

tabs = Tabs(tabs=[ tab1])

p1.legend.click_policy=“hide”

display plot

show(tabs)

What do I need to change to display the graph correctly?


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/7bb97c28-826a-4b21-b45e-cab795b31534%40continuum.io.

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