Hello Bokeh community!
The export png function appears to lose most the formatting thats done to the text in a plot while exporting it to png. Not sure what is the issue here.
Here’s a sample code which produces intentionally formatted plots but doesn’t retain upon export. I have tried exporting it to a mounted drive location and also to run time. Beither seems to work.
Environment: Google Colab
from collections import OrderedDict
from io import StringIO
from math import log, sqrt
from bokeh.io import curdoc, output_notebook
output_notebook()
import numpy as np
import pandas as pd
from bokeh.plotting import figure, output_file, show
from bokeh.models import ColumnDataSource, Label, LabelSet, Range1d
x = [1,2,3,4,5,6,7,8,9,10,12,15,20,25,30]
y = [256,254,253,253,254,258,262,265,269,272,276,281,289.0,297.0,305.0]
source = ColumnDataSource(data=dict(tenor=[1,2,3,4,5,6,7,8,9,10,12,15,20,25,30],
bps=[256,254,253,253,254,258,262,265,269,272,276,281,289.0,297.0,305.0],
))
p = figure(plot_width=900, plot_height=200,x_range=(0.5, 30.5), y_range=(230, 320))
# add both a line and circles on the same plot
p.line(x, y, color="#571F01",line_width=2)
p.circle(x, y, fill_color="#FFECBD", size=8)
p.xaxis[0].axis_label = 'Tenor(Y)'
p.yaxis[0].axis_label = 'bps'
p.xaxis.axis_label_text_font = 'Georgia'
labels = LabelSet(x='tenor', y='bps', text='bps',
text_font_size="12px",text_font = "Calibri",text_color ="#571F01" ,
level='glyph', x_offset=-10, y_offset=5, source=source, render_mode='canvas')
p.xaxis.major_tick_line_color = None # turn off x-axis major ticks
p.xaxis.minor_tick_line_color = None # turn off x-axis minor ticks
p.xaxis.major_label_text_font = 'Georgia'
p.yaxis.major_tick_line_color = None # turn off y-axis major ticks
p.yaxis.minor_tick_line_color = None # turn off y-axis minor ticks
p.xaxis.major_label_text_color = None # turn off x-axis tick labels leaving space
p.yaxis.major_label_text_color = None # turn off y-axis tick labels leaving space
#p.xgrid.grid_line_color = None
p.ygrid.grid_line_color = None
p.yaxis.visible = False
p.yaxis.axis_label = 'bps'
p.add_layout(labels)
p.varea(source=source, x='tenor', y1=230, y2="bps", alpha=0.2, fill_color='#FFECBD', )
show(p)
export_png(p, filename="plot.png")