Cannot change tab title in browser

What are you trying to do?

I am trying to change the title shown in the tab in chrome when spawning a bokeh graph into the browser with show(…) so that it does not have the default “Bokeh Plot”

What have you tried that did NOT work as expected?


show(p, title=“My new title”)

also tried

curdoc().title = “My new title”

I only see Bokeh Plot in the tab no matter what I try

Could it be that every time you call curdoc() a different instance is created? The following works on my side:

from bokeh.plotting import curdoc
doc = curdoc()
doc.title = 'My Title'

Thankyou for the response, but I am having no luck with that

from import show, curdoc

        p = column(vals_fig, jitter_fig)

        doc = curdoc()
        doc.title = 'My Title'

Still shows “Bokeh Plot” in the browser tab title.

Everything else works great!

@big_red_frog please (always) provide relevant version information.

Yep, apologies ( did I miss in the template? Though brain should of done it anyway )

Pretty sure I am on 3.1.0

I will check actual later when on host PC

Associated code is at

Everything else is working as hoped.

Can’t understand what I am missing. Ready to kick self.

Thanks for the version info @big_red_frog unfortunately what you linked is not a Minimal Reproducible Example. An MRE should be self-contained, and bereft of any extraneous code not directly related to the issue at hand. I would expect and MRE for thies to be in the low tens of lines, at most.

So let’s try another approach. When I run this example:

bokeh/ at branch-3.2 · bokeh/bokeh · GitHub

with bokeh serve --show and Bokeh 3.1, I see the tab with the title “Sliders” as expected:

What happens when you run it? If you don’t get a tab with the expected title, then maybe this is some platform-specific issue, and so we would need detailed information about browser, OS, versions, etc. to have any hope of reproducing. If you do see the expected title, then you’ll need to greatly pare down you code to a self-contained, complete, minimal reproducible example so that we can easily look at the problem in isolation.

That seems to run fine, I see tab title of “slides” as expected.

Noting in my case I am running a show call from within an active python application, rather than Bokeh server. Let me see if I can hack that simple example for a show(…) implemention.

I had missed that aspect. Does show(curdoc()) change anything?

I cannot get the figure itself to show with my basic approach, as I assume it is differences in runtime launch of bokeh and server implementation.

However, I do get the sliders, by adding a simple


at the end of the script and just running that.

Once more I am back to “Bokeh Plot” in the browser tab.

I will try this shortly…

Changing the code within the provided script to

# Set up layouts and add to document
inputs = column(text, offset, amplitude, phase, freq)

curdoc().add_root(row(inputs, plot, width=800))
curdoc().title = "Sliders"


I get

Traceback (most recent call last):
  File "C:\Users\atod\PycharmProjects\bokeh1\", line 77, in <module>
  File "C:\Users\atod\PycharmProjects\bokeh1\amber\Lib\site-packages\bokeh\io\", line 154, in show
    raise ValueError(_BAD_SHOW_MSG)
ValueError: Invalid object to show. The object to passed to show must be one of:

* a UIElement (e.g. a plot, figure, widget or layout)
* a Bokeh Application
* a callable suitable to an application FunctionHandler

Actually scratch that, I was thinking of the BokehJS API. I think you are just running into some historical rough edges of Bokeh where original intended usage was a little different (because it was created way before the server existed). There seem to be a few ways to specify a title in the non-server case, but setting curdoc().title does not appear to be one so them. I think your options are:

  • call save (not show) since it accepts a title param
  • call output_file with the desired title before every call to show

My understanding is that both of those would force the creation of a file as well as the launched browser session. Is it possible to change the tab title without saving the html file, or is it required ( currently )

I am afraid I guess I don’t understand your situation or what you are trying to do. show also saves a file. There is no way to open a browser to show Bokeh HTML content without saving a corresponding file.

This (more or less) is all show does:

It’s always been that way and I would not expect it to change. If you don’t provide a filename, Bokeh will try to pick one based on the name of the current script. Perhaps that was confusing into thinking there was not a file being saved.

I am spawning a browser tab with all graphs required from runtime python code, so once displayed in the browser, I don’t expect to edit it further, but as I spawn a few seperate bokeh tabs, I want the user to be able to identify which tab is of interest via its title.

If bokeh save a file anyway, then I guess I should try manipulating the file title, I had not realised this.

However the following test code does not work either, sitll generating a tab of “Bokeh Plot”

import numpy as np

from import curdoc, output_file
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure, show

# Set up data
N = 200
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
source = ColumnDataSource(data=dict(x=x, y=y))

# Set up plot
plot = figure(height=400, width=400, title="my sine wave",
              x_range=[0, 4*np.pi], y_range=[-2.5, 2.5])

plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)


output_file has a title parameter

Thanks, that works, using title= in output_file(…)

I will spend a little time on managing the filename path implied so there are not problems there and use this method for my purposes.

1 Like

That is now working with some code to clean the title and reuse it as a filename

        save_as = os.path.join(get_default_config_directory(),
                               f"{re.sub('[^A-Za-z0-9]+', '_', compound)}.html")
        output_file(filename=save_as, title=compound)

I did not see a file being saved anywhere through bare calls to show(…), but this is sustainable.

Bokeh will save the output in an OS-provided temp-filename location: bokeh/ at branch-3.2 · bokeh/bokeh · GitHub

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.