ARIMA model in plotly

How do you display plots created by the arima library (statsmodels.tsa.arima_model) onto plotly? I tried returning results.plot_predict() in my update_graph function, but I get

InvalidCallbackReturnValue: The callback for [<Output graph.figure>, <Output stage.figure>, <Output discharge.figure>, <Output stage_forecast.figure>] returned a value having typetuple which is not JSON serializable.

Hi @ToastFrench, I’d have to see exactly what the callback is returning to accurately diagnose the problem but basically Dash callbacks can only return strings, numerical arrays, or dictionaries or tuples made up of only strings and/or numerical arrays.

1 Like

Hi @nickest, thanks for your reply.

This is briefly what my code looks like to return the forecast graph.

model = ARIMA(idf_logscale, order=(1,1,1))
results_ARIMA =
forecast = results_ARIMA.plot_predict(1,3000)
return forecast

This is what it looks like if I print it inline

Is it possible to convert into an HTML element somehow?

Ah, the plot it is returning is a matplotlib plot. I’ve never tried, but you can maybe use matplotlylib to convert it to a Plotly figure which would then be compatible with Dash.

You can also embed the matplotlib chart as an image Reusing code written with matplotlib in Dash