Hi, I can use a curdoc theme that affects how charts appears in the browser, but is it possible to get that theme to also apply to charts generated via export_png? At the moment I can’t do both.
Here is some example code:
dates = pd.date_range(“20210101”, periods=6)
df = pd.DataFrame(np.random.randn(6, 2), index=dates, columns=list(“AB”))
df.rename_axis(‘Date’, axis=0, inplace=True)
source = ColumnDataSource(df)
curdoc().theme = Theme(filename=“global_theme.json”)
s1 = figure(width=972, height=589)
s1.title.text = “A”
s1.line(x=‘Date’,
y=‘A’,
source = source,
color=‘green’,
legend_label=‘Overall sentiment’)
s2 = figure(width=972, height=589)
s2.title.text = ‘B’
s2.line(x=‘Date’,
y=‘B’,
source = source,
color=‘green’,
legend_label=‘Sales’)
charts = [s1, s2]
def format(chart):
chart.yaxis.formatter = NumeralTickFormatter(format=“0”)
chart.xaxis.formatter = DatetimeTickFormatter(months="%b %Y")
export_png(chart, filename = +chart.title.text+’.png’)
return chart
s1, s2, = [format(chart) for chart in charts]
show(s1)
And this is the theme json:
{
“attrs”:{
“Axis”: {
“axis_label_text_font”: “Georgia”,
“axis_label_text_font_size”: “15px”,
“major_label_text_font” : “Georgia”,
“major_label_text_font_size” : “15px”
},
“Title”: {
“text_font_style”: “bold”,
“text_font”: “Georgia”,
“text_font_size” : “25px”
},
“Legend”: {
“label_text_font”: “Georgia”,
“label_text_font_size”: “20pt”
}
}
}