Thanks to GPT4 and a lot of persistence i eventually worked out a very simple way to get it done. I post it here in case anyone as amateur as me ever wants to update a matplotlib chart with new data on a schedule. The only gripe I have is that matplotx(dracula) isn’t accepted as figure style although i use it everywhere else.
# Function to update the plot
def update_plot(event=None):
prices = get_data()
fig = pcht(prices)
mpl_pane.object = fig
table_pane.object = display_table(prices)
# Create an initial plot
prices = get_data()
fig = pcht(prices)
table = display_table(prices)
mpl_pane = pn.pane.Matplotlib(fig, sizing_mode='stretch_width')
table_pane = pn.pane.DataFrame(table)
# Set up periodic callback to update the plot every 5 minutes
pn.state.add_periodic_callback(update_plot, 270000) # 27000ms = 4.5 minutes
# Layout for the Panel
layout = pn.Column(mpl_pane,table_pane,max_width=450,max_height=600)
# Serve the Panel
layout.servable()
great product panel but I’ve chewed up a lot of time and despite best efforts the documentation remains difficult for an amateur like me.