Svg element not showing when saving plot

I am trying to save a plot that includes svg elements.

When I specify the relative svg path, the image will show on the plot, but not in the png that I save.

When I specify the absolute svg path, the image will not show on the plot, but do so when I save it.

The minimal example would be:

from bokeh.plotting import figure
from bokeh.io.export import get_screenshot_as_png
from bokeh.io import show

image_url = …

p = figure(x_range=(0,1), y_range=(0,1))
p.image_url([img_url], x=0.5, y=0.5, w=1, h=1, anchor=‘center’)
show§

img = get_screenshot_as_png§
img.save(‘img.png’)

“”“same with export_png(p, png.png)”""

This is happening both when working in a notebook or using a server app.

How can I get the svg elements to both show on the plot and on the saved image?

@znstrider image_url is a very oddball glyph, having to asynchronously load external resources unlike every other glyph. I would be fairly surprised if it works with SVG export. You can file a github issue to begin some investigation, but I can’t promise that this combination of usage can be made workable.

Thanks for the reply @Bryan I will file the issue.

1 Like