from bokeh.plotting import figure, show
from bokeh.io import output_file
from bokeh.models import ColumnDataSource
from bokeh.io import export_png
output_file("line.html")
p = figure(title="Simple line example", x_axis_label='x', y_axis_label='y')
p.line([1, 2, 3, 4], [6, 7, 2, 4], line_width=2)
# Remove background
p.background_fill_color = None
p.border_fill_color = None
# Remove grid lines
p.xgrid.grid_line_color = None
p.ygrid.grid_line_color = None
# Remove axis
p.axis.visible = False
p.grid.visible = False
text_data = {'x': [3], 'y': [6], 'text': ['Hello, Bokeh!']}
source = ColumnDataSource(text_data)
p.text(x='x', y='y', text='text', source=source, text_align='center', text_baseline='middle', text_color='black', text_font_size='20pt')
# show(p)
output_filename = "output_image.png"
export_png(p, filename=output_filename)
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.