You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not able to change the title text of a figure interactively. In the minimal working example below, the title stays "old title" even after clicking the button. In the non-interactive version, this works fine.
Bokeh version 1.1.0.
Running on Windows 10, Anaconda environment, bokeh serve --show opens Firefox browser.
from bokeh.models.annotations import Title
from bokeh.plotting import figure, show
from bokeh.models.widgets import Button
from bokeh.layouts import row
import numpy as np
from bokeh.io import curdoc
x = np.arange(0, 2*np.pi, np.pi/100)
y = np.sin(x)
p = figure(title="old title")
p.circle(x, y)
button = Button(label="Update available curves", button_type="success")
def on_button():
t = Title()
t.text = 'new title'
p.title = t
print("Clicked")
button.on_click(on_button)
curdoc().add_root(row(p, button))
The title text stays the same. No error / warning shown in the console. "Clicked" is printed, so the function is definitely executed.
The text was updated successfully, but these errors were encountered:
The best practice and guidance in general for Bokeh is always: make the smallest change possible. In this specific case that means updating the text on the existing title, not replacing the Title object wholesale (which is a much more cumbersome operation). This principle is how things are demonstrated across the board in bokeh docs and examples.
cc @mattpap That said we should figure out things in this case (or make Title objects themselves readonly so that they can only be updated not replaced... I am somewhat inclined to do this in several places for the future)
bryevdv
changed the title
[BUG] Updating title text in bokeh server does not work
[BUG] Updating title object in bokeh server does not work
Apr 23, 2019
Thanks for the quick response. I initially tried to change the title itself, not realizing it is an object with a "text" attribute. I then got the idea to change the whole object from a stackoverflow thread, where this was the accepted (but not most upvoted) answer... Your solution works for me.
I am not able to change the title text of a figure interactively. In the minimal working example below, the title stays "old title" even after clicking the button. In the non-interactive version, this works fine.
Bokeh version 1.1.0.
Running on Windows 10, Anaconda environment,
bokeh serve --show
opens Firefox browser.The title text stays the same. No error / warning shown in the console. "Clicked" is printed, so the function is definitely executed.
The text was updated successfully, but these errors were encountered: