Saving figure as HTML in specified folder

Hello everyone,

I would like to save my bokeh figures to the files that I specified with using output_file command with the code given below but it still saves the HTML where the code is in.

from bokeh.plotting import figure, gridplot, output_file, save,show


p1 = figure(plot_width=400, plot_height=400)
p1.circle([1, 2, 3], [4, 5, 6])


p2 = figure(plot_width=400, plot_height=400)
p2.line([1, 2, 3], [4, 5, 6])

grid = gridplot([[p1, p2]])


output_folder = "C:/Users/xxx/xxxx/saveplot"


file_name = 'my_grid.html'

# Specify the full file path
output_file(root_dir=output_folder, filename=file_name,mode = 'relative')
 
# Save the grid as HTML
save(grid)

Hi @araratcetinkaya you should specify the full path as filename. The root_path parameter has to do with where BokehJS resources are loaded from, it does not control output location.

From the docs:

root_dir (str, optional) : root directory to use for 'absolute' resources. (default: None)
    This value is ignored for other resource types, e.g. ``INLINE`` or ``CDN`

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