Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Generating Your First Figure to a Static HTML File

Give Feedback

This video will show you how to output your Bokeh visualation to a static HTML file. Bokeh will generate all of the HTML and Javascript automatically for you, when you run your script.

More information about output_file() can be found in the Bokeh official docs.

File: FirstFigure.py

# Bokeh Libraries
from bokeh.io import output_file
from bokeh.plotting import figure, show

# The figure will be rendered in a static HTML file
# called output_file_test.html
output_file('output_file_test.html', 
            title='Empty Bokeh Figure')

# Set up a generic figure() object
fig = figure()

# See what it looks like
show(fig)

Kalesis on Sept. 8, 2019

Hello In the sample code, the object figure() was missing. regards

hayatmor on March 18, 2020

WARNING:bokeh.core.validation.check:W-1000 (MISSING_RENDERERS): Plot has no renderers: Figure(id=‘1002’, …)

soultion

>>> from bokeh.core.validation import silence
>>> from bokeh.core.validation.warnings import EMPTY_LAYOUT
>>> silence(EMPTY_LAYOUT, True)

rickecon on March 26, 2020

Working on a macOS Catalina (v. 10.15.3). I set up the environment as specified. When I run my FirstFigure.py, I get a blank browser window in Chrome with the following error:

WARNING:bokeh.core.validation.check:W-1000 (MISSING_RENDERERS): Plot has no renderers: Figure(id='1001', ...)

My code for FirstFigure.py is the following, which I think is exactly as demonstrated:

# Bokeh libraries
from bokeh.io import output_file
from bokeh.plotting import figure, show

# The figure will be rendered in a static HTML file called output_file_test.html
output_file('output_file_test.html', title='Empty Bokeh Figure')

# Set up a generic figure object
fig = figure()

# See what it looks like
show(fig)

I tried using the previous comment’s suggestion which is the same in the bokeh user guide of adding the core.validation settings at import, which resulted in the same error and the same blank browser window.

# Bokeh libraries
from bokeh.io import output_file
from bokeh.plotting import figure, show
from bokeh.core.validation import silence
from bokeh.core.validation.warnings import EMPTY_LAYOUT
silence(EMPTY_LAYOUT, True)

# The figure will be rendered in a static HTML file called
# output_file_test.html
output_file('output_file_test.html', title='Empty Bokeh Figure')

# Set up a generic figure object
fig = figure()

# See what it looks like
show(fig)

I saw in the bokeh user guide that id='1001' means BAD_COLUMN_NAME: “A glyph has a property set to a field name that does not correspond to any column in the GlyphRenderer’s data source.” But I didn’t specify any properties in the code above.

Please advise.

rickecon on March 26, 2020

UPDATE: If I open the HTML file generated in each of the examples above using Safari, it looks fine. So my fix is the following.

show(fig, browser='safari')

Any idea why Chrome produces a blank figure?

Chris Bailey RP Team on March 26, 2020

Hi @rickecon, Thanks for your comments. As Bokeh has updated it looks like this “Warning” was added, and makes this portion of the course a bit more awkward. The lessons going forward all have rendering. The idea of the lesson was to show the bare minimum of how to make an ‘empty’ plot. So the warning makes sense, there are no renderers. I will look at ways to update this particular lesson as the Bokeh package moves forward.

rickecon on March 28, 2020

Thanks Chris. For some reason, the problem has gone away. The only thing I updated was Xcode developer tools. But everything works great now.

R morel on May 20, 2020

show_in = ‘safari’

Become a Member to join the conversation.