from bokeh.plotting import figure, show
import base64
from bokeh.models import ColumnDataSource
image_path = "./input_image.png"
def image_to_base64(file_path):
with open(file_path, 'rb') as img_file:
return base64.b64encode(img_file.read()).decode('utf-8')
encoded_image = image_to_base64(image_path)
html_image = f'data:image/png;base64,{encoded_image}'
plot = figure(x_range=(0, 1), y_range=(0, 1), output_backend="webgl")
plot.image_url(url=[html_image], x=0, y=1, w=1, h=1)
text_data = {'x': [0.5], 'y': [0.5], 'text': ['Hello123, Bokeh123!']}
source = ColumnDataSource(text_data)
plot.text(x='x', y='y', text='text', source=source, text_align='center', text_baseline='middle', text_color='black',
text_font_size='20pt')
show(plot)
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.