Prophet: How to save image with plot_components?

Created on 28 Mar 2017  Â·  6Comments  Â·  Source: facebook/prophet

I am wondering if I can use plot_components and later save the figures to an image.
I tried this

`plt = m.plot_components(forecast)

plt.savefig('output')`

however plot_components returns a list and not a matplotlib figure. Hence the error was thrown...

Traceback (most recent call last): File "get_predictions.py", line 33, in <module> plt.savefig(output_file) AttributeError: 'list' object has no attribute 'savefig'

Any ideas is very much appreciated.

Most helpful comment

This is what I use and it works...
m.plot_components(forecast).savefig('2.png');

All 6 comments

This is what I use and it works...
m.plot_components(forecast).savefig('2.png');

Thanks @guiled will try that one.

Unfortunately that didn't work either p.s. I'm not doing this on a notebook

Traceback (most recent call last): File "get_predictions.py", line 31, in <module> m.plot_components(forecast).savefig(detailed_file) AttributeError: 'list' object has no attribute 'savefig'

Hello,
I have the same problem:
m.plot(forecast).savefig('Prophet_Forecast.png'); works all right
but m.plot_components(forecast).savefig('Prophet_Components.png'); does not work with the same error as @arvindacumos:
AttributeError: 'list' object has no attribute 'savefig'
Thanks in advance
Stéphane

@robertdknight thanks can you provide more detailed code?

how to save image into folder?

Was this page helpful?
0 / 5 - 0 ratings