For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

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:
    <IPython.core.display.Javascript object>
    <IPython.core.display.HTML object>

    Any suggestions on how to overcome the issue? Thanks!


  • administrators

    Not being even a beginner in the usage of IPython

    1. Anaconda has nothing to do with this. It's a distribution.

    2. Jupyter is the graphical frontend and as such meant for plotting

    3. IPython is focused on interactive Python, i.e.: it is a console.

    Try plotting disabling the ipython automatic detection when calling plot



  • 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!



  • 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.)


Log in to reply
 

});