cerebro.plot() does not work with Anaconda / IPython
It appears that the cerebro.plot() command only works in Jupyter, but not in IPython (similarly here). I get the following error:
Any suggestions on how to overcome the issue? Thanks!
Not being even a beginner in the usage of
Anaconda has nothing to do with this. It's a distribution.
Jupyter is the graphical frontend and as such meant for plotting
IPython is focused on interactive Python, i.e.: it is a console.
Try plotting disabling the
ipythonautomatic detection when calling
Thanks for the explanation. cerebro.plot(iplot=False) alongside changing the graphics backend in Spyder (Tools/Preferences/IPython Console/Graphics) now allows me to plot it via the IPython console.
//edit: When I select "inline", it seems like it worked once, but now the figure window freezes. When I select "Automatic" or anything else, I get the error message "ImportError: Cannot load backend 'TkAgg' which requires the 'tk' interactive framework, as 'qt5' is currently running". Any solution to this?
//edit2: The freeze can be delayed by adding plt.pause(10) after cerebro.plot(iplot=False). In that case, i can at least see and 'use' the figure. I would still be happy about comments on it. Thanks!
sobeasy last edited by
having the same problems here, and no kidding, it was killing me.
I spent hours and hours to figure the solution and even pycharm can't help. ( Don't know why )
I tried subclass the "backtrader.plot.Plot" but still not working.
If you really want to use spyder, here is the trick :
import backtrader.plot import matplotlib matplotlib.use('QT5Agg') # Your running code cerebro.plot(iplot= False)
Remember to select your Graphic backend to "Qt5" in spyder.
You should see the windows pop out (It can even be maximizing ! how great...)
I am using win10 , Anaconda , Spyder 3.3.2 , Py 3.7.1, Ipyhon 7.2.0
(User from Hong Kong. Thanks for the platform, it's really great.)
Possible fix: https://github.com/mementum/backtrader/pull/423
Thank you - this was very annoying, but your solution worked! :)