Prophet: Components plots doubling in Jupyterlab

Created on 28 Dec 2017  ·  7Comments  ·  Source: facebook/prophet

When plotting model components charts in Jupyterlab, they appear twice:

screenshot from 2017-12-28 11-03-16

In the notebook, I have set %matplotlib inline, so the charts are plotted directly below notebook cells.

Most helpful comment

You can place a ';' behind your statement in order to get the plot only once. I think this is due to the fact that the plot is already rendered in the function.

All 7 comments

You can place a ';' behind your statement in order to get the plot only once. I think this is due to the fact that the plot is already rendered in the function.

Correct, it is because jupyter will automatically render any matplotlib plots, and will in addition to that print the output of the last line in the cell (in this case the figure, hence the duplication). Semicolon will suppress printing the last line in the cell so you'll get it only once. Alternatively you can assign the output of plot to a variable and it won't print the 2nd time:

fig = model.plot_components(forecast)

OK. It is worth noting that this behavior seems inconsistent when compared with plotting the timeseries data using model.plot(). In other words model.plot() and model.plot_components() would ideally behave the same.

that's interesting, for me they do behave the same (both print duplicates without ;, and print one with ;), which is what I would expect since both of these method return a matplotlib fig object. What behavior are you experiencing?

In Jupyter Lab the model components plot doubles while the model plot prints normally (without the trailing ; in each case). I am not sure if JupyterLab is the deciding factor, but that is just what I am using in this case.

Oh interesting, I haven't tried JupyterLab. Both functions return matplotlib figures so I can't imagine why JupyterLab would be treating the outputs differently.

I'm going to close this since I don't think there is any changes to be made here, at least until JupyterLab usage picks up.

Was this page helpful?
0 / 5 - 0 ratings