I am trying to update my Bokeh plots using different widgets. I have been updating the ColumnDataSource and the data has been updated successfully, but anything other than the data points isnt being updated on my Bokeh plots. In specific, I am trying to update the Y-axis scale and the title of my plots from the ColumnDataSource, and they do not get updated from my callback function. Below is an example of how I am trying to update the Y-axis scale.
#scaling the y-axis
minimum_ranges = {'WAC': 0.25, 'WALA': 15, 'AOLS': 25000, 'WAOLT':10, 'WAOLTV':10, 'WAOCS': 25}
if y in minimum_ranges:
data_range = data_source.data[y].max() - data_source.data[y].min()
if data_range < minimum_ranges[y]:
scale_diffrence = minimum_ranges[y] - data_range
p.y_range.start = data_source.data[y].min() - scale_diffrence/2
p.y_range.end = data_source.data[y].max() + scale_diffrence/2
My callback just generates a new pandaframe, and updates the ColumnDataSource accordingly.
def callback(attr,old, new):
#-----------------------------------------------------------------------------------------------
story = story_text.value
coupon = coupon_text.value
vintage = vintage_text.value
try:
cb_df = generate_df(start_date, end_date, vintage, coupon, story)
cohorts_source.data.update({'key1': ["1MO", "3MO", "6MO", "12MO"],
'key2': [round(cb_df[var][0]*100, 2) for var in ["CPR_1MO", "CPR_3MO", "CPR_6MO", "CPR_12MO"]]})
CPR_plot.title = "NEW TITLE"
except:
pass
Do you have any suggestions for how I can update the Y-axis and the title of my plots based on widgets data?