Why is Bokeh's plot not changing with plot selection?

前端 未结 1 1186
挽巷
挽巷 2021-01-27 20:47

Struggling to understand why this bokeh visual will not allow me to change plots and see the predicted data. The plot and select (dropdown-looking) menu appears

相关标签:
1条回答
  • 2021-01-27 21:09

    Your update_plot is a no-op that does not actually make any changes to Bokeh model state, which is what is necessary to change a Bokeh plot. Changing Bokeh model state means assigning a new value to a property on a Bokeh object. Typically, to update a plot, you would compute a new data dict and then set an existing CDS from it:

    source.data = new_data  # plain python dict
    

    Or, if you want to update from a DataFame:

    source.data = ColumnDataSource.from_df(new_df)
    

    As an aside, don't assign the .data from one CDS to another:

    source.data = other_source.data  # BAD
    

    By contrast, your update_plot computes some new data and then throws it away. Note there is never any purpose to returning anything at all from any Bokeh callback. The callbacks are called by Bokeh library code, which does not expect or use any return values.

    Lastly, I don't think any of those last JS console errors were generated by BokehJS.

    0 讨论(0)
提交回复
热议问题