When I try to run my python script in command prompt, it throws the error given below, while it works fine in Ipython. The issue is closed in Matplotlib repository (https://github.com/matplotlib/matplotlib/issues/11016). They believe it is related to fbprophet.
INFO:matplotlib.backends._backend_tk:Could not load matplotlib icon: can't use "pyimage10" as iconphoto: not a photo image
m = Prophet()
m.fit(Dataframe)
future = m.make_future_dataframe(periods= 80, freq= 'M')
forecast = m.predict(future)
m.plot(forecast)
m.plot_components(forecast);
I found out that using both m.plot(forecast) and m.plot_components(forecast) at the same time causes the "pyimage10" error. However, this does not solve my problem either. (https://github.com/matplotlib/matplotlib/issues/11016). I get no errors, but matplotlib does not pop up..
@Glutch if running in the command prompt the plot would not pop up unless you explicitly tell matplotlib to show it. Try this:
fig = m.plot(forecast)
fig.show()
and then does it pop-up?
There certainly seems to be an issue here but I'm highly skeptical that it is an fbprophet issue since we're just doing pretty vanilla plotting with matplotlib and then returning the figure object. But let's try to see if we can come up with a reproducible failure that uses only matplotlib. I'll try to repro this on a windows machine but in the meantime, based on @Glutch 's comment I'm wondering if the issue only happens when plotting both of them? Does
fig1 = m.plot(forecast)
fig2 = m.plot_components(forecast)
fig1.show()
fig2.show()
error? Does
fig1 = m.plot(forecast)
fig1.show()
fig2 = m.plot_components(forecast)
fig2.show()
error?
I have followed the official prophet "quick start guide" https://facebook.github.io/prophet/docs/quick_start.html#python-api
This does not pop up matplotlib
fig = m.plot(forecast)
fig.show()
Both of your code examples gives me the pyimage10 error. Sidenote: There is a small window that flashes very quickly. Could be matplotlib trying to accomplish something (Same as hassheh linked, but mine closes instantly)
I tried
fig = m.plot(forecast)
fig.show()
Im only able to see a small window without any graph.
The result is same for
fig1 = m.plot(forecast)
fig2 = m.plot_components(forecast)
fig1.show()
fig2.show()
fig1 = m.plot(forecast)
fig1.show()
fig2 = m.plot_components(forecast)
fig2.show()
When I try this on the Anaconda prompt, I also have that fig.show() produces a blank window, but it does work for me if I actually import matplotlib and use the module's show command, like this:
from matplotlib import pyplot as plt
fig1 = m.plot(forecast)
fig2 = m.plot_components(forecast)
plt.show()
Does that work for you?
At least for me, fig.show() not working is an issue in matplotlib; it also doesn't work with this code:
from matplotlib import pyplot as plt
fig = plt.figure(1)
ax = fig.add_subplot(111)
ax.plot([1, 2, 3], [1, 2, 3])
fig.show()
plt.show()
Works for me. But it still throws the same error
INFO:matplotlib.backends._backend_tk:Could not load matplotlib icon: can't use "pyimage10" as iconphoto: not a photo image
It doesn't matter though as long as it works. Thanks.
That seems to be logged at INFO level and not ERROR, so I'm guessing it's harmless.
@Glutch This other page should help you out if you haven't already fixed this already.
Basically, the docs don't tell you that you need to import matplotlib.pyplot as plt and use it to plot the figure.
Adding %matplotlib inline in my notebook helped fwiw
plt.show() got it fixed
Most helpful comment
When I try this on the Anaconda prompt, I also have that
fig.show()produces a blank window, but it does work for me if I actually import matplotlib and use the module'sshowcommand, like this:Does that work for you?